我是靠谱客的博主 威武小海豚,最近开发中收集的这篇文章主要介绍c语言oj签到题,2017下半年ACM-ICPC网络赛签到题汇总,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

青岛站

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

#include

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("YESn");

}else {

printf("NOn");

}

}

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

#include

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("%dn", s);

}

}

最后

以上就是威武小海豚为你收集整理的c语言oj签到题,2017下半年ACM-ICPC网络赛签到题汇总的全部内容,希望文章能够帮你解决c语言oj签到题,2017下半年ACM-ICPC网络赛签到题汇总所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(37)

评论列表共有 0 条评论

立即
投稿
返回
顶部