HDU-5832 HDU-1212/2016网络选拔赛/大数取余

来源:互联网 发布:h3c 查看端口状态 编辑:程序博客网 时间:2024/05/16 08:02

A water problem

Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 326    Accepted Submission(s): 180


Problem Description
Two planets named Haha and Xixi in the universe and they were created with the universe beginning.

There is 73 days in Xixi a year and 137 days in Haha a year.

Now you know the days N after Big Bang, you need to answer whether it is the first day in a year about the two planets.
 

Input
There are several test cases(about 5 huge test cases).

For each test, we have a line with an only integer N(0N), the length of N is up to 10000000.
 

Output
For the i-th test case, output Case #i: , then output "YES" or "NO" for the answer.
 

Sample Input
100010333
 

Sample Output
Case #1: YESCase #2: YESCase #3: NO
 

Author
UESTC
 

Source
2016中国大学生程序设计竞赛 - 网络选拔赛

Cmod(A*B)==0  =CmodA==0&&CmodB==0
 
   C
---------- =integer
  A*B
#include <iostream>
using namespace std;
#define N 12000000
#define INF 1<<30
char s[N];
int main()
{
    int k=0,len,x,d,i;
    while(scanf("%s", s) != EOF)
    {
        k++;
        len = strlen(s);
        x=10001;
        d=0;
        for(i=0;i<len;i++)
            d=(d*10+(s[i]-'0')%x)%x;

        if(d==0)
            printf("Case #%d: YES\n",k);
        else
            printf("Case #%d: NO\n",k);
    }
    return 0;
}

Big Number

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7409    Accepted Submission(s): 5124


Problem Description
As we know, Big Number is always troublesome. But it's really important in our ACM. And today, your task is to write a program to calculate A mod B.

To make the problem easier, I promise that B will be smaller than 100000.

Is it too hard? No, I work it out in 10 minutes, and my program contains less than 25 lines.
 

Input
The input contains several test cases. Each test case consists of two positive integers A and B. The length of A will not exceed 1000, and B will be smaller than 100000. Process to the end of file.
 

Output
For each test case, you have to ouput the result of A mod B.
 

Sample Input
2 312 7152455856554521 3250
 

Sample Output
251521
 

Author
Ignatius.L
 

Source
杭电ACM省赛集训队选拔赛之热身赛

#include <iostream>
#include<string.h>
using namespace std;
#define N 1005
char s[N];
int main()
{
  int k=0,len,x,d,i;
   while(scanf("%s",s)!= EOF) {
        cin>>x;
        k++;
        len = strlen(s);
        d=0;
      for(i=0;i<len;i++)
            d=(d*10+(s[i]-'0')%x)%x;
        printf("%d\n",d);
   }
  return 0;
}
0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 打篮球一打比赛就紧张怎么办 耐克空军鞋鞋底边胶掉了怎么办 鞋底踩到老鼠胶怎么办 头蒙怎么办最快最有效 备孕老公压力大怎么办 宝宝太兴奋不睡怎么办 我很烦只睡三小时觉怎么办才好 柯基精力太旺盛怎么办 孩子学习熬夜精力不足怎么办 肺癌晚期吃不下饭怎么办 这俩天吃药太多肝肾功能不好怎么办 跑步跑得头疼晕怎么办 吃完辣的想吐怎么办 体育生暑假训练太累怎么办 高强度运动后性功能不好怎么办 运动后第二天全身酸痛怎么办 运动后心慌想吐怎么办 激素停后全身疼怎么办 运动完头晕想吐怎么办 跑了步全身酸痛怎么办 运动后全身没力气怎么办 学完游泳不会换气怎么办 猫不吃饭精神不好怎么办 运动完头晕目眩想吐怎么办 酒后第二天恶心想吐怎么办 剧烈运动后肌肉酸痛怎么办 剧烈运动后吐了怎么办 长跑后头晕想吐怎么办 运动后一直想吐怎么办 跑多了恶心想吐怎么办 剧烈运动恶心想吐怎么办 长跑之后 恶心想吐怎么办 喝咖啡后绞心痛怎么办 牛奶喝多了胃胀怎么办 运动后大量出汗头晕怎么办 屁股出汗淹的特别痛怎么办 运动完感觉很累怎么办 跑步后感觉很累怎么办 输液多了伤脾胃怎么办 运动完后特别晕怎么办 运动过量大腿肌肉酸痛怎么办