URAL - 1243 - Divorce of the Seven Dwarfs (大数取模)
来源:互联网 发布:数据分析处理是什么 编辑:程序博客网 时间:2024/06/05 19:07
1243. Divorce of the Seven Dwarfs
Time limit: 1.0 second
Memory limit: 64 MB
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
123456123456
1
Problem Author: Stanislav Vasilyev
Problem Source: Ural State University Personal Programming Contest, March 1, 2003
Problem Source: Ural State University Personal Programming Contest, March 1, 2003
Tags: none
)开始刷刷URAL。。先水一个
AC代码:
#include <map>#include <set>#include <cmath>#include <deque>#include <queue>#include <stack>#include <cstdio>#include <cctype>#include <string>#include <vector>#include <cstdlib>#include <cstring>#include <iostream>#include <algorithm>#define LL long long#define INF 0x7fffffffusing namespace std;char s[105];int main() {scanf("%s", s);int len = strlen(s);int ans = s[0] - '0';for(int i = 1; i < len; i ++) {ans = (ans * 10 + s[i] - '0') % 7;}printf("%d\n", ans);return 0;}
0 0
- URAL - 1243 - Divorce of the Seven Dwarfs (大数取模)
- URAL 1243 Divorce of the Seven Dwarfs
- URAL 1243. Divorce of the Seven Dwarfs
- poj1912:A highway and the seven dwarfs(凸包)
- Snow White and the Seven Dwarfs
- POJ 1912 A highway and the seven dwarfs 已翻译
- poj1912 A highway and the seven dwarfs【凸包+二分】
- POJ 1912 A highway and the seven dwarfs(O(log N)求直线与凸包是否相交)
- The seven layer of the osi model
- POJ2635--The Embarrassed Cryptographer--大数取模
- (POJ2635)The Embarrassed Cryptographer(大数取模)
- The Embarrassed Cryptographer poj2635 (大数取模)
- POJ 1912 A highway and the seven dwarfs (凸包&O(logN)判断直线是否与凸包相交)
- URAL 1180 Stone Game 博弈 找规律 大数取模 除3取模
- The Seven Characteristics of a Tight Organization
- Save the dwarfs
- hdu4314Save the dwarfs【dp】
- hdu4314Save the dwarfs 【dp】
- shell 文件操作
- TOYS (poj 2381 叉积+二分)
- mysql管理日常命令
- linux串口编程实现---有图有真相
- android 使用Theme + attr换肤
- URAL - 1243 - Divorce of the Seven Dwarfs (大数取模)
- python-minidom模块【解析xml】
- android解析,组包XML文件
- Molar mass
- ActionBar隐藏修改图标和标题
- java 中字符拼接学习心得
- C#高级编程四十七天----集合接口和类型
- #leetcode#Valid Palindrome
- 如何实现左滑返回(2)