首页 > 代码库 > HDUJ 1212 Big Number
HDUJ 1212 Big Number
Big Number
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4622 Accepted Submission(s): 3198
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.
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 3 12 7 152455856554521 3250
Sample Output
2 5 1521
JAVA;
import java.util.Scanner; import java.math.BigInteger; public class yhrtr { public static void main(String[] args) { Scanner cin = new Scanner (System.in); BigInteger a,b,c; while(cin.hasNext()) { a = cin.nextBigInteger(); b = cin.nextBigInteger(); c = a.mod(b); System.out.println(c); } } }
C++;
#include<iostream> #include<cstring> using namespace std; int main() { char c[1005]; int m; while(cin>>c>>m) { int l=strlen(c); __int64 s=0; for(int i=0;i<l;i++) { s=(s*10+c[i]-'0')%m; } printf("%I64d\n",s); } return 0; }
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。