洛古最简单50题解(31-40)

Posted aybengwa

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了洛古最简单50题解(31-40)相关的知识,希望对你有一定的参考价值。

做为一名新手,首先要过一过题,找找成就感。(大佬略过)。下面附上洛古最简单50题(大佬略过)。以及最麻烦 AC代码,至少AC了

NO.31 P1615 西游记公司

#include<iostream>
using namespace std;
int main()

????long long a1,a2,a3,s1,s2,s3,x,n;
????char m;
????cin>>a1>>m>>a2>>m>>a3>>s1>>m>>s2>>m>>s3>>x;
????n=((s1-a1)*3600+(s2-a2)*60+(s3-a3))*x;
????cout<<n;

?

NO.32 P1634 禽兽的传染病

#include<iostream>
using namespace std;
int main()

????long long n=1,x,y;
????cin>>x>>y;
????for (long long i=1;i<=y;i++)
????
????????n+=x*n;
????
????cout<<n;

?

NO.33 P1720 月落乌啼算钱

#include <cstdio>
#include <cmath>
using namespace std;
int main()

int n;
scanf("%d",&n);
printf("%.2f",(pow(((1+sqrt(5))/2),n)-pow(((1-sqrt(5))/2),n))/sqrt(5));
return 0;

?

NO.34 P1760 通天之汉诺塔


#include<bits/stdc++.h>
using namespace std;
long long k=2,n;
#include<iostream>
using namespace std;
int a[15001];
int main()

int n;
a[1]=1;
cin>>n;
if(n==0)
a[1]=0;
for(int i=2;i<=n;i++)

for(int k=1;k<=i-1;k++)
a[k]*=2;
for(int k=1;k<=i-1;k++)
if(a[k]>=10)

a[k]-=10;
a[k+1]++;

a[1]++;

int p=15001;
while(a[p]==0&&p!=1)

p--;

for(int i=p;i>=1;i--)
cout<<a[i];
return 0;

?

NO.35 P1909 买铅笔

#include<iostream>
using namespace std;
int main()

????int a1,a2,a3,b1,b2,b3,n,t1,t2,t3;
????int d;
????cin>>n>>a1>>b1>>a2>>b2>>a3>>b3;
????t1=n/a1*b1;
????if (n%a1 != 0)
????
????????t1+=b1;
????
????t2=n/a2*b2;
????if (n%a2 != 0)
????
????????t2+=b2;
????
????t3=n/a3*b3;
????if (n%a3 != 0)
????
????????t3+=b3;
????
????d=t1;
????if (d>t2)
????d=t2;
????if (d>t3)
????d=t3;
cout<<d<<endl;
????return 0;

?

NO.36 P1980 计数问题

#include<iostream>
using namespace std;
int main()

long long n,i,x,b,c,t=0;
cin>>n>>x;
for(i=1;i<=n;i++)

b=i;
while(b!=0)

c=b%10;
b=b/10;
if(c==x) t++;


cout<<t<<endl;
return 0;

?

NO.37 P2084 进制转换2

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()

????char a[1001];
????int b;
????scanf("%d ",&b);
????gets(a);
????for (int i=0;i<strlen(a);i++)
????
????????if(i!=0 && a[i] != ‘0‘)
????????
????????????cout<<"+";
????????
????????if(a[i] == ‘0‘)
????????
????????????continue;
????????
????????printf("%c*%d^%d",a[i],b,strlen(a)-i-1);
????
????return 0;

?

NO.38 P2141 珠心算测验

#include<bits/stdc++.h>
using namespace std;
int n,s=0,a[101],f[20001];
int main()

????cin>>n;
????for(int i=0;i<n;i++)
????????cin>>a[i];
????for(int i=0;i<n-1;i++)
????????for(int j=i+1;j<n;j++)
????????????f[a[i]+a[j]]=1;
????????for(int i=0;i<n;i++)
????if(f[a[i]]) s++;
????cout<<s;

?

NO.39 P2239 螺旋矩阵

#include<bits/stdc++.h>
using namespace std;
int jk(int n, int i, int j)

if (i == 1)
return j;
if (j == n)
return n + i - 1;
if (i == n)
return 3 * n - 2 - j + 1;
if (j == 1)
return 4 * n - 4 - i + 2;
return jk(n - 2, i - 1, j - 1) + 4 * (n - 1);

int main()

????int n,i1,j1;
????cin>>n>>i1>>j1;
/*
????if(i1>j1)
????
????????x=j1;
????????x2=i1;
????
????else
????
????????x=i1;
????????x2=j1;
????
????if(n % 2==0 && x2>n/2)
????
????????x=n/2-(x2-n/2)+1;
????
????if(n % 2==1 && x2>=n/2+1)
????
????????x=n/2+1-(x2-(n/2+1));
????
????int x3;
????x3=n-1;
????x2=4*x3;
????for(int i=n/2;i!=x;i--)
????
????????x2+=4*x3;????
????????x3=n-2;
????
????
????int i=x,j=x;
????t=0;
????while(i!=i1&&j!=j1)
????
????????t++;
????????if(x3!=t)
????????
????????????i++;
????????
????????else
????????
????????????t=0;
????????????if (i=x+x3+1&&j)
????????????
????????????????
????????????
????????
????

//????a[0]=x3+x+1;
//????a[1]=x3+x*2+1;
????int i=i1-x+1,j=j1-x+1;

????if(i==1||j==4)
????
????????t=i+j-1;
????
????else
????
????????t=i+j-1+2*x3-i+j;
????
????cout<<t+x2;
????/

*/
????cout<<jk(n,i1,j1);

?

NO.40 P2672 推销员

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define inf 100000
#define pr
printf
#define sc scanf
#define ll long long
using namespace std;

struct S

int a;
int s;
int c;
st[inf+1];
int n;
ll ans;
bool cmp(S a,S b)
return a.a>b.a;

void swap(S &a,S &b)
S c;
c=a;a=b;b=c;
return;

int main()
sc("%d",&n);
for(int i=1;i<=n;i++)sc("%d",&st[i].s);
for(int i=1;i<=n;i++)sc("%d",&st[i].a),st[i].c=i;

for(int j=1;j<=n;j++)
if(((st[1].s<<1)+st[1].a)<((st[j].s<<1)+st[j].a))swap(st[1],st[j]);

sort(st+2,st+n+1,cmp);
ans+=(st[1].s<<1);
for(int i=1;i<=n;i++)
if(st[i].s<=st[1].s)ans+=st[i].a;
else
ans=ans+((st[i].s-st[1].s)<<1);
st[1].s=st[i].s;
ans+=st[i].a;

cout<<ans<<‘\n‘;

return 0;
//
这题一点都不简单

以上是关于洛古最简单50题解(31-40)的主要内容,如果未能解决你的问题,请参考以下文章

洛古 P2679 子串 题解

查分约束例题(洛古)

[题解]UVa 12661 Funny Car Racing - spfa

洛古1028

数据库增删改查最简单练习

村村通(洛古)