27: divided by 13, 27 divided by 13
27: divided by 13
- View
- Submit
- Statistics
- Question
-
Total time limit:
-
1000 ms
-
Memory limit:
-
65536kB
-
Description
-
Enter a large integer N greater than 0, with a length of no more than 100 characters. divide it by 13 to get the quotient and remainder.
-
Input
-
A large integer greater than 0 with a length of no more than 100 characters.
-
Output
-
The two rows are the quotient and remainder obtained by integer division.
-
Sample Input
-
2132104848488485
-
Sample output
-
1640080652683450
-
Prompt
-
In a simulated division operation, the quotient length should be 1 or 2 less than the length of the input large integer.
-
Source
-
Exercise (12-11)
-
1 # include <iostream> 2 # include <cstdio> 3 # include <cstring> 4 using namespace std; 5 char a1 [10001]; 6 int a [10001]; 7 int c [10001]; 8 int main () 9 {10 gets (a1); 11 int la = strlen (a1); 12 for (int I = 0; I <la; I ++) 13 {14 a [I + 1] = a1 [I]-48; 15} 16 int x = 0; // vendor 17 for (int I = 1; I <= la; I ++) 18 {19 c [I] = (x * 10 + a [I]) /13; 20 x = (x * 10 + a [I]) % 13; 21} 22 int lc = 1; 23 for (int I = 1; I <= la; I ++) 24 {25 if (c [I] = 0 & lc <la) 26 lc ++; 27 else break; 28} 29 for (int I = lc; I <= la; I ++) 30 cout <c [I]; 31 cout <endl; 32 cout <x; 33 return 0; 34}