加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

URAL - 1243 - Divorce of the Seven Dwarfs (大数取模)

发布时间:2020-12-14 02:27:56 所属栏目:大数据 来源:网络整理
导读: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

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?≤ 10 50) .

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
)



开始刷刷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 0x7fffffff
using 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("%dn",ans);
	return 0;
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读