1243. Divorce of the Seven Dwarfstime limit:1.0 second
Memory limit:64 Mbafter The Snow white with she bridegroom had left the house of the Seven Dwarfs, their peaceful and pro Sperous life have come to an end. Each dwarf blames others to being the reason of the Snow white ' s leave. To stop everlasting quarrels, the dwarfs decided to part. According to a ancient law, their common possessions should is divided in the most fair the, which means it all the DWA RFS should get equal parts. Everything that the dwarfs cannot divide in a fair the it they give to the Snow white. For example, after dividing-boots, each dwarf got 3 old boots, and the Snow White got the remaining 5 old boots. Some of the numbers is very large, for example, the dwarfs has 123456123456 poppy seeds, so it's isn't easy to calculate That's the Snow white gets only one seed. The divorce, help the dwarfs to determine quickly the Snow White's part. Inputthe contains an integer
NThat represents the number of similar items, the Dwarfs want to divide (1≤
N≤1050). Outputyou 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()difficulty:57 Test Instructions: Output X%7 analysis: high-precision Division
1#include <cstdio>2#include <cstring>3#include <algorithm>4#include <iostream>5 using namespacestd;6 Const intN = the;7 intArr[n], N;8 CharStr[n];9 #defineFor (I, S, T) for (int i = (s); I <= (t); i++)Ten One intMain () A { -scanf"%s", Str +1); -n = strlen (Str +1); thefor (I,1, n) arr[i] = Str[i]-'0'; - intLast =0; -for (I,1, N) - { +Last = last *Ten+Arr[i]; -Last%=7; + } Acout << Last <<Endl; at return 0; -}
View Code
Ural 1243. Divorce of the Seven dwarfs