Ural 1243. Divorce of the Seven dwarfs

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.