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

開始刷刷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("%d\n", ans);
return 0;
}

URAL - 1243 - Divorce of the Seven Dwarfs (大数取模)的更多相关文章

  1. ural 1243. Divorce of the Seven Dwarfs

    1243. Divorce of the Seven Dwarfs Time limit: 1.0 secondMemory limit: 64 MB After the Snow White wit ...

  2. hdu2302(枚举,大数取模)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2303 题意:给出两个数k, l(4<= k <= 1e100, 2<=l<=1 ...

  3. (POJ2635)The Embarrassed Cryptographer(大数取模)

    The Embarrassed Cryptographer Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 13041 Accep ...

  4. 【大数取模】HDOJ-1134、CODEUP-1086

    1086: 大数取模   题目描述 现给你两个正整数A和B,请你计算A mod B.为了使问题简单,保证B小于100000. 输入 输入包含多组测试数据.每行输入包含两个正整数A和B.A的长度不超过1 ...

  5. HDU4704Sum 费马小定理+大数取模

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4704 题目大意: 看似复杂,其实就是求整数n的划分数,4=1+1+2和4=1+2+1是不同的.因而可 ...

  6. HDU--1212大数取模

    大数取模问题.题目传送门:HDU1212 #include <iostream> using namespace std; char a[1010]; int main() { int b ...

  7. ACM-ICPC 2018 焦作赛区网络预赛G Give Candies(隔板定理 + 小费马定理 + 大数取模,组合数求和)题解

    题意:给你n个东西,叫你把n分成任意段,这样的分法有几种(例如3:1 1 1,1 2,2 1,3 :所以3共有4种),n最多有1e5位,答案取模p = 1e9+7 思路:就是往n个东西中间插任意个板子 ...

  8. HPU 1471:又是斐波那契数列??(大数取模)

    1471: 又是斐波那契数列?? 时间限制: 1 Sec 内存限制: 128 MB 提交: 278 解决: 27 统计 题目描述 大家都知道斐波那契数列吧?斐波那契数列的定义是这样的: f0 = 0; ...

  9. 题解报告:hdu 1212 Big Number(大数取模+同余定理)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1212 Problem Description As we know, Big Number is al ...

随机推荐

  1. 小学生绞尽脑汁也学不会的python(异常,约束,MD5加密,日志处理)

    小学生绞尽脑汁也学不会的python(异常,约束,MD5加密,日志处理) 异常处理(处理) 1.产生异常.raise 异常类(),抛出异常2. 处理异常: try: xxxxx # 尝试执行的代码. ...

  2. 在join中,on和where的区别

    两个表在,join时,首先做一个笛卡尔积,on后面的条件是对这个笛卡尔积做一个过滤形成一张临时表,如果没有where就直接返回结果,如果有where就对上一步的临时表再进行过滤. 在使用left  j ...

  3. java几种读写文件的方式

    java.io的几种读写文件的方式 一.java把这些不同来源和目标的数据都统一抽象为数据流. Java语言的输入输出功能是十分强大而灵活的. 在Java类库中,IO部分的内容是很庞大的,因为它涉及的 ...

  4. spring boot pom

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

  5. HDU 2512

    水题 #include <iostream> #include <cstdio> #include <algorithm> #define LL __int64 # ...

  6. Dalvik虚拟机垃圾收集(GC)过程分析

    前面我们分析了Dalvik虚拟机堆的创建过程,以及Java对象在堆上的分配过程. 这些知识都是理解Dalvik虚拟机垃圾收集过程的基础.垃圾收集是一个复杂的过程,它要将那些不再被引用的对象进行回收.一 ...

  7. yqj2065经典语录

    在上课时.博客中和<编程导论(Java)>书中,yqj2065说过一些简短的话.列举一些玩玩. 假设您在我的博客中看见好玩的,最好还是推荐一下. 持续加入中... 1. "噢姐姐 ...

  8. [BLE--Link Layer]设备蓝牙地址

    简述 不论什么网络设备而言,都会有自己独特的一个MAC地址,不然在设备量较大的情况下非常可能造成通信的混乱.蓝牙是无线通信中使用非常广泛的技术.当然其蓝牙地址也是相当的重要的了. 蓝牙地址简述 种类划 ...

  9. spring web mvc第一天

    spring  web mvc 感觉就是高大上啊!啥都是配置文件就能够了.所以第一步就是弄清楚配置文件使用和总体框架的流程! Spring web mvc最重要的当然是Controller,也就是首先 ...

  10. UVA - 10689 Yet another Number Sequence 矩阵快速幂

                      Yet another Number Sequence Let’s define another number sequence, given by the foll ...