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

Posted aybengwa

tags:

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

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

NO.41 P2676 超级书架

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

????int i,n,b,ans,m;
????int a[100001];
????cin>>n>>b;
????for(int i=0;i<n;i++)
????
????????cin>>a[i];
????
????sort(a,a+n);
????i=n;
????ans=0;
????m=0;
????while (m<b)
????
????????m+=a[i--];
????????++ans;
????
????cout<<ans-1<<endl;
????return 0;

?

NO.42 P2788 数学1(math1)- 加减算式

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

while(cin>>t) ans+=t;
cout<<ans;
return 0;

?

NO.43 P2955 [USACO09OCT]奇数偶数Even Odd

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

????long long n,i;
cin>>n;
????string a;
for (i=1; i<=n; i++)

cin>>a;
if ((a[a.size()-1]-‘0‘)%2==0)

????????cout<<"even"<<endl;
????????
????????else
????????
????????cout<<"odd"<<endl;
????????

return 0;

?

NO.44 P3150 pb的游戏(1)

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

????int n,t;
????int a[100001];
????cin>>n;
????for(int i=1;i<=n;i++)
????
????????cin>>t;
????????if (t % 2 ==0)
????????a[i]=1;
????????else
????????a[i]=0;
????
????for (int i=1; i<=n;i++)
????
????????if (a[i]==1)
????????cout<<"pb wins\n";
????????else
????????cout<<"zs wins\n";
????
????return 0;

?

NO.45 P3912 素数个数

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

????int n;
????cin>>n;

?

NO.46 P3954 成绩

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

????float a,b,c,n;
????scanf("%f%f%f",&a,&b,&c);
????n=a*0.2+b*0.3+c*0.5;
????printf("%.0f",n);
????return 0;

?

NO.47 P4325 [COCI2006-2007#1] Modulo

//1:

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

????int a[10],n=0;
for (int i=1;i<=10;i++)

????cin>>a[i];
????a[i]=a[i]%42;
????
????for (int i=1;i<=10;i++)
????
????????for (int j=1;j<=10;j++)
????????
????????????if(a[i]==a[j] && i!=j)
????????????
????????????a[i]=-1;
????????
????????
????????if (a[i]!=-1)
????????
????????????n++;
????????
????
????cout<<n<<endl;



//2:

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

????int a[10],n=0;
for (int i=1;i<=10;i++)

????cin>>a[i];
????a[i]%=42;
????????for (int j=1;j<=i;j++)
????????
???????? if(a[i]==a[j] && i!=j)
???????????? a[i]=-1;
????
????
????for (int i=1;i<=10;i++)
????????if (a[i]!=-1)
????????n++;
????cout<<n<<endl;



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

????int a[10],n=0;
for (int i=1;i<=10;i++)

???? cin>>a[i];
????a[i]%=42;
????????for (int j=1;j<=i;j++)
???????? if(a[i]==a[j] && i!=j) a[i]=-1;
????????if (a[i]!=-1)n++;
????
????cout<<n<<endl;

?

NO.48 P4413 [COCI2006-2007#2] R2

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

float s,r1,r2;
????scanf("%f%f",&r1,&s);
????r2=(s-r1/2)*2;
????printf("%.0f",r2);
????return 0;

?

NO.49 [洛古]T48131 【高精度】求n!的值

#include <bits/stdc++.h>
int n,a[100000],l1 =1;
void input_data()

scanf("%d",&n);
for (int i = 1; i <= 999;i++)
a[i] = 0;
a[1] = 1;

void get_ans()

for (int i = 1;i <= n;i++)

int x = 0;
for (int j = 1;j <= l1;j++)

a[j] = a[j] *i + x;
x = a[j] / 10;
a[j] = a[j] % 10;

while ( x > 0)

l1++;
a[l1] += x;
x = a[l1] / 10;
a[l1] = a[l1] % 10;



void output_ans()

for (int i = l1;i >= 1;i--)
printf("%d",a[i]);

int main()

input_data();
get_ans();
output_ans();
return 0;

?

NO.50 ??

#include<bits/stdc++.h>
using namespace std;
???
int main()
????--???????--
return 0;

第五十题,我故意设置了一个悬念,绝对不会告诉你,是因为之前把49数成了50

欢迎大家把自己的想法发给我:[email protected]

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

洛古 P2679 子串 题解

查分约束例题(洛古)

[题解]UVa 12661 Funny Car Racing - spfa

洛古1028

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

村村通(洛古)