zoukankan      html  css  js  c++  java
  • 训练计划,水题

    http://poj.org/problem?id=2017

    #include <iostream>
    
    using namespace std;
    
    int main()
    {
        ios::sync_with_stdio(false);
        int n;
        while(cin>>n && n != -1)
        {
            int s, t;
            int sum = 0;
            cin>>s>>t;
            n--;
            sum += s * t;
            while(n--)
            {
                int t2;
                cin>>s>>t2;
                sum += (t2-t) * s;
                t = t2;
            }
            cout << sum << " miles" <<endl;
        }
    }

    http://poj.org/problem?id=1218

    #include <stdio.h>
    
    using namespace std;
    
    int main()
    {
        int n,m,i,j,x=0,k=0,str[1024];
        scanf("%d",&n);
        for(i=1; i<=n; i++)
        {
            k=0;
            scanf("%d",&m);
            for(int t=1; t<=m; t++)
            {
                x=0;
                for(j=1; j<=t; j++)
                {
                    if(t%j==0)
                    {
                        x++;
                    }
                }
                if((x%2)!=0)
                {
                    k++;
                }
            }
            str[i]=k;
        }
        for(i=1; i<=n; i++)
        {
            printf("%d
    ",str[i]);
        }
    }

    h ttp://poj.org/problem?id=2000

    #include <stdio.h>
    
    using namespace std;
    
    int main()
    {
    	int n;
    	while(~(scanf("%d", &n)))
    	{
    		if(n == 0)break;
    		else
    		{
    			int sum=0;
    			int i;
    			for(i=1;i<=150;i++)
    			{
    				sum+=i*i;
    				if(((i+1)*i)/2 >= n)
    				break;
    			}
    			sum=sum-(((i+1)*i)/2-n)*i;
    			printf("%d %d
    ", n, sum);
    		}
    	}
    }
    

    http://poj.org/problem?id=1046

    #include<stdio.h>
    #include<math.h>
    
    int main()
    {
        int a[26],b[26],c[26],d,i,x,y,m,z,min;
        for(i=1; i<=16; i++)
        {
            scanf("%d%d%d",&a[i],&b[i],&c[i]);
        }
        while(scanf("%d%d%d",&x,&y,&z)!=EOF)
        {
            if(x==-1 && y==-1 && z==-1)
                break;
            min=1<<30;
            for(i=1; i<=16; i++)
            {
                d=(int)((a[i]-x)*(a[i]-x)+(b[i]-y)*(b[i]-y)+(c[i]-z)*(c[i]-z));
                if(d<min)
                {
                    m=i;
                    min=d;
                }
            }
            printf("(%d,%d,%d) maps to (%d,%d,%d)
    ",x,y,z,a[m],b[m],c[m]);
        }
    }
    

    http://poj.org/problem?id=1003

    #include <stdio.h>
    
    int main()
    {
    	double sr,count;
    	int js,i;
    	while(scanf("%lf",&sr)!=EOF)
    	{
    		js=1;
    		count=0;
    		if(sr==0.00)
    		{
    			break;
    		}
    		for(i=2;i<300;i++)
    		{
    			if(sr>(count+1.0/i))
    			{
    			count=count+(1.0/i);
    			js++;
    			}
    			else
    			{
    				break;
    			}
    		}
    		
    		printf("%d card(s)
    ",js);
    	}
    }

    http://poj.org/problem?id=1004

    #include<cstdio>
    #include<cstring>
    
    int main()
    {
        double m;
        while(scanf("%lf",&m)!=EOF)
        {
    	double ans=m;
    	for(int i=1;i<12;i++)
    	{
    	    scanf("%lf",&m);
    	    ans+=m;
    	}
    	printf("$%.2lf
    ",ans/12);
        }
    }

    http://poj.org/problem?id=1005

    #include<cstdio>
    #include<cstring>
    
    int main()
    {
        int T,cas=1;
        scanf("%d",&T);
        while(T--)
        {
    	double ita,itb;
    	scanf("%lf%lf",&ita,&itb);
    	double s=(ita*ita+itb*itb)*3.14/2;
    	int ans=(int)(s/50)+1;
    	printf("Property %d: This property will begin eroding in year %d.
    ",cas++,ans);
        }
        printf("END OF OUTPUT.
    ");
    }

    http://poj.org/problem?id=1008

    #include <stdio.h>
    #include <string.h>
    
    int main()
    {
        char str1[19][7]= { "pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu", "uayet" };
        char str2[20][9]= { "imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau" };
        int day, year, days, mon, i, t;
        char month[9];
        scanf("%d", &t);
        printf("%d
    ", t);
        while (t--)
        {
            scanf("%d. %s %d", &day, month, &year);
            for (i= 0; i < 19; i++)
            {
                if ( !strcmp(month, str1[i]) )
                {
                    break;
                }
            }
            days= year*365 + i*20 + day;
            year= days/260;
            mon= (days%260)%20;
            day= (days%260)%13;
            printf("%d %s %d
    ", day+1, str2[mon], year);
        }
    }

    http://poj.org/problem?id=1013

    #include<stdio.h>
    #include<math.h>
    #include<string.h>
    
    char str1[10],str2[10],str3[10];
    int mark[15],num[15];
    
    int main()
    {
        int cas,v,i,j,max;
        scanf("%d",&cas);
        while(cas--)
        {
            v=3;
            for(i=0; i<12; i++)
            {
                mark[i]=num[i]=0;
            }
            while(v--)
            {
                scanf("%s%s%s",str1,str2,str3);
                if(!strcmp(str3,"even"))
                {
                    for(i=0; i<strlen(str1); i++)
                    {
                        mark[str1[i]-'A']=mark[str2[i]-'A']=1;
                    }
                }
                else if(!strcmp(str3,"up"))
                {
                    for(i=0; i<strlen(str1); i++)
                    {
                        num[str1[i]-'A']++;
                        num[str2[i]-'A']--;
                    }
                }
                else
                {
                    for(i=0; i<strlen(str1); i++)
                    {
                        num[str1[i]-'A']--;
                        num[str2[i]-'A']++;
                    }
                }
            }
            max=-1;
            j=0;
            for(i=0; i<12; i++)
            {
                if(!mark[i] && max<abs(num[i]))
                {
                    max=abs(num[i]);
                    j=i;
                }
            }
            if(num[j]<0)
            {
                printf("%c is the counterfeit coin and it is light.
    ",j+'A');
            }
            else
            {
                printf("%c is the counterfeit coin and it is heavy.
    ",j+'A');
            }
        }
    }
    

    http://poj.org/problem?id=1207

    #include <stdio.h>
    #include <stdlib.h>
    
    
    int main()
    {
        int i,j,m,n,k,max;
        int p,q;
        while(scanf("%d%d",&p,&q)==2)
        {
            max=0;
            i=p;
            j=q;
            if(p>q)
            {
                j=p;
                i=q;
            }
            for(m=i; m<=j; m++)
            {
                k=m;
                n=1;
                while(k!=1)
                {
                    if(k%2)
                        k=3*k+1;
                    else k=k/2;
                    n++;
                }
                if(n>max) max=n;
            }
            printf("%d %d %d
    ",p,q,max);
        }
    }

    http://poj.org/problem?id=1552

    #include <stdio.h>
    
    int main()
    {
        int array[1005];
        int i,j,k;
        int n;
        while(1)
        {
            scanf("%d",&array[1]);
            if(array[1] == -1) break;
            for(n = 2; ; n++)
            {
                scanf("%d",&array[n]);
                if(array[n] == 0) break;
            }
            int ans = 0;
            for(i = 1; i < n; i++)
            {
                for(j = 1; j < n; j++)
                    if(array[j]*2 == array[i])
                    {
                        ans++;
                        break;
                    }
            }
            printf("%d
    ",ans);
        }
    }
    

    http://poj.org/problem?id=2105     裸位运算

    #include <stdio.h>
    #include <string.h>
    
    using namespace std;
    
    int main()
    {
        char buff[20000];
        int temp[5];
        int n;
        unsigned ip;
        scanf("%d",&n);
        while (n--)
        {
            ip=0;
            scanf("%s",buff);
            for (int i=0; i<32; ++i)
            {
                (ip<<=1)|=(buff[i]-'0');
            }
            for (int i=1; i<=4; ++i)
            {
                temp[i] = ip & ((1 << 8) - 1);
                ip >>= 8;
            }
            for (int i=4; i>=1; --i)
            {
                printf(i==1?"%d
    ":"%d.",temp[i]);
            }
        }
    }
    

    http://poj.org/problem?id=2388

    #include<stdio.h>
    #include<iostream>
    #include<algorithm>
    
    using namespace std;
    
    int main()
    {
        int a[10010];
        int i,n;
        scanf("%d",&n);
        for (i=0; i<n; i++)
        {
            scanf("%d",&a[i]);
        }
        sort(a,a+n);
        printf("%d
    ",a[(n-1)/2]);
    }
    

    http://poj.org/problem?id=1316 

    #include<stdio.h>
    
    int main()
    {
        int a[10001]= {0};
        int i, b, c;
        for(i=0; i<10001; i++)
        {
            b=i;
            c=i;
            while (b)
            {
                c+=b%10;
                b/=10;
            }
            if(c<=10000)
            {
                a[c]=1;
            }
        }
        for(i=0; i<10001; i++)
        {
            if(a[i]!=1)
            {
                printf("%d
    ",i);
            }
        }
    }
    

    http://poj.org/problem?id=3006

    #include <stdio.h>
    #include <math.h>
    
    int prime(int x)
    {
        int i, j;
        j = sqrt(x);
        if (x < 2)
        {
            return 0;
        }
        else if (x == 2)
        {
            return 1;
        }
        for (i = 2; i <= j; i++)
        {
            if (x % i == 0)
            {
                return 0;
            }
        }
        return 1;
    }
    
    int main()
    {
        int a, d, n, m, i, count;
        while (scanf("%d %d %d", &a, &d, &n) != EOF)
        {
            if (a == 0 && d == 0 && n == 0)
            {
                break;
            }
            count = 0;
            for (i = 0; count != n; i++)
            {
                m = a + i * d;
                if (prime(m))
                {
                    count++;
                }
            }
            printf("%d
    ", m);
        }
    }
    


    水题没意思,换C语言风格为C语言期末考试,别忘了scanf和printf的用法。

    自今天起到期末(7.11)止,不再开电脑,不再敲代码。目标:高数95+,线代95+,C语言90+,英语85+,大物85+。再开电脑就剁手!!!








  • 相关阅读:
    git的冲突解决--git rebase之abort、continue、skip
    iOS 13苹果登录
    mac上python3.x安装 图文详解
    iOS Bezier曲线
    《从零开始学Swift》学习笔记(Day 23)——尾随闭包
    《从零开始学Swift》学习笔记(Day 22)——闭包那些事儿!
    《从零开始学Swift》学习笔记(Day 21)——函数返回值
    《从零开始学Swift》学习笔记(Day 20)——函数中参数的传递引用
    《从零开始学Swift》学习笔记(Day 19)——函数参数传递
    《从零开始学Swift》学习笔记(Day 18)——有几个分支语句?
  • 原文地址:https://www.cnblogs.com/dyllove98/p/3141067.html
Copyright © 2011-2022 走看看