POJ之路

声明:作者是ACM初学者,列出的有些程序可能过于简单,请大牛们无视之~~

THIS IS A TEST CODE:


1000.A+B Problem

#include<stdio.h>

int  main(){

    int a,b;

    scanf("%d,%d",&a,&b);

    printf("%d",a+b);

    return 0;

}

1003 Hangover

#include<stdio.h>
int main(){
double c;
    while(scanf("%lf",&c) && c!=0.00){
       //printf("%lf \n",c);
       float sum =0.0;
       int i;
       for(i=2;sum<c;i++){
      sum += (1.0/i);
       }
       printf("%d card(s)\n",i-2);
    }
    return 0;
}

1004 Financial Management

#include <stdio.h>
int main()
{   
float pay[12];
float sum;
int i;
sum = 0.00;
for (i = 0; i <= 11; i++)
{
scanf("%f", &pay[i]);
sum += pay[i];
}
printf("$%.2f\n", sum/12);
return 0;
}


1005 I Think I Need a Houseboat

#include <stdio.h>
#include <math.h>
int main()
{
int count;
double x,y;
scanf("%d",&count);
int i;
for(i=0;i<count;i++)
{
scanf("%lf %lf",&x,&y);
int year = (int)ceil((x*x+y*y)*3.14/100);
printf("Property %d: This property will begin eroding in year %d.\n",i+1,year);
}
printf("END OF OUTPUT.\n");
return 0;
}

1006 Biorhythms

#include <stdio.h>
int get_m(int a, int b, int c)
{
    int ab, ab_r;
    int i, j;
    ab = a*b;
    ab_r = ab%c;
    j = ab;
    for(i = 0; i < c; i ++){
        if(ab % c == 1)
            return ab;
        else
            ab += j;
    }
    return -1;
}

int main()
{
int p, e, i, start, case_count = 0;
int tmp;
while(scanf("%d %d %d %d", &p, &e, &i, &start) != EOF){
if(start == -1){
break;
}
case_count++;
tmp = (p*get_m(28, 33, 23) + e*get_m(23, 33, 28) + i*get_m(23, 28, 33))%21252;
printf("Case %d: the next triple peak occurs in %d days.\n", case_count, (tmp > start) ? (tmp-start):(tmp+21252-start) );
}
return 0;
}

你可能感兴趣的:(poj)