标签:std ret i++ get hoc bre mini length wro
//1
#include<stdio.h>
int main(){
int n;
scanf("%d",&n);
int a[n];
for(int i=0;i<n;i++){
scanf("%d",&a[i]);
}
int sum=0;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(i==j) continue;
else sum+=a[i]*10+a[j];
}
}
printf("%d",sum);
return 0;
}
//2
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
getline(cin,s);
int sum=0;
for(int i=0;i<s.length();i++){
if(isalpha(s[i])){
if(s[i]>=‘A‘&&s[i]<=‘Z‘) sum+=s[i]+32-‘a‘+1;
if(s[i]>=‘a‘&&s[i]<=‘z‘) sum+=s[i]-‘a‘+1;
}
}
int k=0,p=0,q=0;
int m[100000];
while(sum){
m[k++]=sum%2;
if(m[k-1]==0) p++;
if(m[k-1]==1) q++;
sum/=2;
}
printf("%d %d",p,q);
return 0;
}
//3
#include<bits/stdc++.h>
using namespace std;
struct node{
int score;
int right;
char right_cnt[6];
int wrong;
};
int main(){
int n,m;
cin>>n>>m;
node q[m];
for(int i=0;i<m;i++){
int cnt,k=0;
char c;
scanf("%d %d %d",&q[i].score,&cnt,&q[i].right);
q[i].wrong=0;
while((c=getchar())!=‘\n‘){
if(isalpha(c)) q[i].right_cnt[k++]=c;
}
q[i].right_cnt[k]=‘\0‘;
}
int grad[n],t=0,max_error=0;
for(int i=0;i<n;i++){
grad[i]=0;
for(int j=0;j<m;j++){
int cnt,p=0;
char c,choose[6];
scanf("(%d",&cnt);
while((c=getchar())!=‘)‘){
if(isalpha(c)) choose[p++]=c;
}
choose[p]=‘\0‘;
if(cnt==q[j].right&&strcmp(choose,q[j].right_cnt)==0){
grad[i]+=q[j].score;
}else{
q[j].wrong++;
}
if(q[j].wrong>max_error) max_error=q[j].wrong;
getchar();
}
}
for(int i=0;i<n;i++)
printf("%d\n",grad[i]);
if(max_error==0){
printf("Too simple");
}else{
printf("%d",max_error);
for(int i=0;i<m;i++){
if(q[i].wrong==max_error)
printf(" %d",i+1);
}
}
return 0;
}
//4
//1)
#include<stdio.h>
int isprime(int a){
if(a==1) return 0;
for(int i=2;i*i<=a;i++){
if(a%i==0) return 0;
}
return 1;
}
int main(){
int award[10000]={0},n,k,id;
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d",&id);
if(i==0) award[id]=1;
else if(isprime(i+1)) award[id]=2;
else award[id]=3;
}
scanf("%d",&k);
for(int i=0;i<k;i++){
scanf("%d",&id);
switch(award[id]){
case 0: printf("%04d: Are you kidding?\n",id); break;
case 1: printf("%04d: Mystery Award\n",id); award[id]=4;break;
case 2: printf("%04d: Minion\n",id); award[id]=4;break;
case 3: printf("%04d: Chocolate\n",id); award[id]=4;break;
case 4: printf("%04d: Checked\n",id); break;
}
}
return 0;
}
//2)
#include<stdio.h>
int isprime(int a){
if(a==1) return 0;
for(int i=2;i*i<=a;i++)
if(a%i==0) return 0;
return 1;
}
int main(){
int n;
scanf("%d",&n);
int a[n][2];
for(int i=0;i<n;i++){
scanf("%d",&a[i][0]);
a[i][1]=0;
}
int p,q,t=0;
scanf("%d",&p);
for(int i=0;i<p;i++){
scanf("%d",&q);
for(int j=0;j<n;j++){
if(q==a[j][0]){
t++;
if(j==0){
if(a[0][1]==0){
printf("%04d: Mystery Award\n",q);
a[0][1]=1;
break;}
if(a[0][1]==1){
printf("%04d: Checked\n",q);
break;}
}
else if(isprime(j+1)){
if(a[j][1]==0){
printf("%04d: Minion\n",q);
a[j][1]=1;
break; }
if(a[j][1]==1){
printf("%04d: Checked\n",q);
break; }
}else{
if(a[j][1]==0){
printf("%04d: Chocolate\n",q);
a[j][1]=1;
break; }
if(a[j][1]==1){
printf("%04d: Checked\n",q);
break; }
}
}
}
if(t==0){
printf("%04d: Are you kidding?\n",q);
continue;
}
t=0;
}
return 0;
}
//5
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
scanf("%d",&n);
int a[n];
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
sort(a,a+n); //sort默认排序从小到大
int t;
if(a[0]>n){
t=n;
}else{
for(int i=n-1;i>=0 ;i--){
if(a[i]<=n-i){
t=n-i-1;
break;
}
}
}
printf("%d",t);
return 0;
}
标签:std ret i++ get hoc bre mini length wro
原文地址:https://www.cnblogs.com/suying/p/10427900.html