1243. Divorce of the Seven Dwarfs
Time limit: 1.0 second
Memory limit: 64 MB
After the Snow White with her bridegroom had left the house of the seven dwarfs, their peaceful and prosperous life has come to an end. Each dwarf blames others to be the reason of the Snow White‘s leave. To stop everlasting quarrels, the dwarfs decided to part. According to an ancient law, their common possessions should be divided in the most fair way, which means that all the dwarfs should get equal parts. Everything that the dwarfs cannot divide in a fair way they give to the Snow White. For example, after dividing 26 old boots, each dwarf got 3 old boots, and the Snow White got the remaining 5 old boots. Some of the numbers are very large, for example, the dwarfs have 123456123456 poppy seeds, so it is not easy to calculate that the Snow White gets only one seed. To speed up the divorce, help the dwarfs to determine quickly the Snow White‘s part.
Input
The only line contains an integer N that represents the number of similar items that the dwarfs want to divide (1 ≤ N ≤ 1050).
Output
You should output the number of items that pass into the possession of the Snow White.
Sample
input | output |
---|---|
123456123456 |
1 |
Problem Author: Stanislav Vasilyev
Problem Source: Ural State University Personal Programming Contest, March 1, 2003
Tags: none (hide tags for unsolved problems)
Difficulty: 57
题意:输出x%7
分析:高精度除法
1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #include <iostream> 5 using namespace std; 6 const int N = 110; 7 int Arr[N], n; 8 char Str[N]; 9 #define For(i, s, t) for(int i = (s); i <= (t); i++) 10 11 int main() 12 { 13 scanf("%s", Str + 1); 14 n = strlen(Str + 1); 15 For(i, 1, n) Arr[i] = Str[i] - ‘0‘; 16 int Last = 0; 17 For(i, 1, n) 18 { 19 Last = Last * 10 + Arr[i]; 20 Last %= 7; 21 } 22 cout << Last << endl; 23 return 0; 24 }