头像

第一WA者金银花

东阳邪教


访客:14085

离线:7小时前



规律发现后就好多了

但这题有BUG,正确代码还要特判,所以别抄我这个代码

#include<stdio.h>
int n,a[16]={0,0,1};
int main(){
    for(int i=3;i<=30;i++) a[i]=a[i-1]*2;
    while(~scanf("%d",&n),n){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++) printf("%d ",a[i+j]);
            puts("");
        }
        puts("");
    }
}



约数求一下,加起来就完事了

#include<stdio.h>
int n,t,ans;
int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d",&n);
        if(n==1) ans=0;
        else ans=1;
        for(int i=2;i<=n/i;i++) if(!(n%i)){
            ans+=i;
            if(n/i!=i) ans+=n/i;
        }
        if(ans-n) printf("%d is not perfect",n);
        else printf("%d is perfect",n);
        puts("");
    }
    return 0;
} 



用优先队列挺OK的

#include<stdio.h>
#include<queue>
#include<cmath>
using namespace std;
priority_queue<int,vector<int>,greater<int> > q;
int main(int n){
    scanf("%d",&n);
    q.push(1);
    for(int i=2;i<=sqrt(n);i++) if(!(n%i)){
        q.push(i);
        if(n/i!=i) q.push(n/i);
    }
    if(n!=1) q.push(n);
    while(!q.empty()) printf("%d\n",q.top()),q.pop();
    return 0;
} 



我刚开始居然没看懂题目,真是惭愧

#include<stdio.h>
int x,y,n;
int main(){
    while(~scanf("%d",&n)){
        if(n<=0) continue;
        if(!x) x=n;
        else{
            y=n;
            break;
        }
    }
    printf("%d",(2*x+y-1)*y/2);
}



#include<stdio.h>
int main(int n){
    while(~scanf("%d",&n),n){
        for(int i=1;i<=n;i++) printf("%d ",i);
        puts("");
    }
    return 0;
}



#include<stdio.h>
int x,y,ans,t;
int main(){
    scanf("%d",&t);
    while(t--){
        ans=0;
        scanf("%d%d",&x,&y);
        for(int i=(x<y?x:y)+1;i<(x>y?x:y);i++) if(i&1) ans+=i;
        printf("%d\n",ans);
    }
}



输出炒鸡难

#include<stdio.h>
int n,sum,tol,a[4];
char l;
int main(){
    scanf("%d",&n);
    while(n--){
        scanf("%d%s",&sum,&l);
        if(l=='C') a[1]+=sum;
        else if(l=='R') a[2]+=sum;
        else if(l=='F') a[3]+=sum;
    }
    tol=a[1]+a[2]+a[3];
    printf("Total: %d animals\nTotal coneys: %d\nTotal rats: %d\nTotal frogs: %d\nPercentage of coneys: %.2f %\nPercentage of rats: %.2f %\nPercentage of frogs: %.2f %",tol,a[1],a[2],a[3],a[1]*100.0/tol,a[2]*100.0/tol,a[3]*100.0/tol);
}



#include<stdio.h>
int k,n,maxx,ma;
int main(){
    while(~scanf("%d",&k)){
        n++;
        if(k>maxx){
            maxx=k;
            ma=n;
        }
    }
    printf("%d\n%d",maxx,ma);
}



#include<stdio.h>
int n,ans=2;
int main(){
    scanf("%d",&n);
    while(ans<10000) printf("%d\n",ans),ans+=n;
}



#include<stdio.h>
int main(int x,int y,int ans){
    ans=0;
    scanf("%d%d",&x,&y);
    for(int i=(x<y?x:y)+1;i<(x>y?x:y);i++) if(i&1) ans+=i;
    printf("%d",ans);
}