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("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

#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("%d\n", s);

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
统计某十五天内64 位员工的上班迟到早退的次数,星期天和星期六系统自动关闭;假设员工上下班都在标准点±1小时,不存在迟到或早退超过一小时的,其余时间系统自动关闭!迟到早退的次数记录在a.dat 日志分别记录在log_check_in和log_check_out里; 1.员工为我班同学,可比照代码中的结构体初始化的内容; 2.员工号为我班同学学号后3位数字,起始为067,在统计多日迟到累计次数过程有文件内容的修改操作和数据类型转换过程,为简化文件操作过程以及后面的查询过程,实际处理的是员工的序号,如员工号为073的记录为07; 3.签到有时间,如在周六周日不签,在系统关闭情况下,管理员可以进行相关维护操作,管理员密码123456; 4.签到过程记录了员工多日迟到早退的累计次数,更详细的内容写到log文件中,所有这些都可以查询; 5.程序为了更好的实现交互式查询的功能, 循环嵌套写得稍复杂 ; 6.觉得数据库的操作比文本文件的操作更有意义些,对员工信息的定义初始化直接在数组中完成;文件操作起来繁琐,没多大意义,所以打算待学会数据库初始化,数据库访问后再来完善; 7.尚未考虑如何精简程序,合理管理内存,待学会动态内存管理后再回头处理;8.感到不尽人意的是C的“不友好”,没有可视化的界面,没有面向对象语言的种种…… 康师傅 qq 1304622669 再缀:加了控台dos命令调用版缺点优点又都激增,想各程序爱好者给提多多建议,跪拜

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值