2017下半年ACM-ICPC网络赛签到题汇总

来源:互联网 发布:nginx 查看模块 编辑:程序博客网 时间:2024/04/27 10:00

青岛站

Problem Description

A cubic number is the result of using a whole number in a multiplication three times. For example, 3×3×3=27 so 27 is a cubic number. The first few cubic numbers are 1,8,27,64 and 125. Given an prime number p. Check that if p is a difference of two cubic numbers.

Input

The first of input contains an integer T (1≤T≤100) which is the total number of test cases.
For each test case, a line contains a prime number p (2≤p≤1012).

Output

For each test case, output ‘YES’ if given p is a difference of two cubic numbers, or ‘NO’ if not.

#include <stdio.h>#include <math.h>int main(){    int t;    scanf("%d", &t);    while(t--){        long long p;        scanf("%I64d", &p);        p -=1;        long long n = floor(sqrt(p/3));        if(p == 3*n*(n+1)){            printf("YES\n");            }else {            printf("NO\n");        }    }    return 0;} 

Chinese Zodiac

Problem Description

The Chinese Zodiac, known as Sheng Xiao, is based on a twelve-year cycle, each year in the cycle related to an animal sign. These signs are the rat, ox, tiger, rabbit, dragon, snake, horse, sheep, monkey, rooster, dog and pig.
Victoria is married to a younger man, but no one knows the real age difference between the couple. The good news is that she told us their Chinese Zodiac signs. Their years of birth in luner calendar is not the same. Here we can guess a very rough estimate of the minimum age difference between them.
If, for instance, the signs of Victoria and her husband are ox and rabbit respectively, the estimate should be 2 years. But if the signs of the couple is the same, the answer should be 12 years.

Input

The first line of input contains an integer T (1≤T≤1000) indicating the number of test cases.
For each test case a line of two strings describes the signs of Victoria and her husband.

Output

For each test case output an integer in a line.

Sample Input

3
ox rooster
rooster ox
dragon dragon

Sample Output

8
4
12

#include <stdio.h>#include <string.h>int shengXiao(char a[8] ){    int n;    if(strcmp(a, "rat")==0){        n = 12;    }else if(strcmp(a, "ox")==0){        n = 11;    }else if(strcmp(a,"tiger")==0){        n = 10;    }else if(strcmp(a, "rabbit")==0){        n = 9;    }else if(strcmp(a, "dragon")==0){        n = 8;    }else if(strcmp(a, "snake")==0) n = 7;    else if(strcmp(a,"horse")==0) n = 6;    else if(strcmp(a,"sheep")==0) n = 5;    else if(strcmp(a,"monkey")==0) n = 4;    else if(strcmp(a, "rooster")==0) n = 3;    else if(strcmp(a,"dog")==0) n = 2;    else if(strcmp(a, "pig")==0) n = 1;    return n;}int main(){    int t;    scanf("%d", &t);    while(t--){        char z[8],w[8];        scanf("%s%s", &z, &w);        int n = shengXiao(z);        int m = shengXiao(w);        int s = n-m;        if(s <= 0){            s += 12;        }         printf("%d\n", s);    } }
阅读全文
0 0