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. qml与c++混合编程

    QML 与 C++ 混合编程内容:1. QML 扩展2. C++ 与 QML 交互3. 开发时要尽量避免使用的 QML 元素4. demo 讲解5. QML 语法C++ 与 QML 的交互是通过注册 ...

  2. 洛谷P1004 方格取数

    网络流大法吼 不想用DP的我选择了用网络流-- 建模方法: 从源点向(1,1)连一条容量为2(走两次),费用为0的边 从(n,n)向汇点连一条容量为2,费用为0的边 每个方格向右边和下边的方格连一条容 ...

  3. SpringBoot 消费NSQ消息

    使用监听器,来实现实时消费nsq的消息 一.目前spring boot中支持的事件类型如下 ApplicationFailedEvent:该事件为spring boot启动失败时的操作 Applica ...

  4. C++11时间具体解释

    转载请注明出处:http://blog.csdn.net/luotuo44/article/details/46854229 C++ 11添加了三个与时间相关的类型:时间段.时钟.时间点. 以史为鉴 ...

  5. HDUOj 看病要排队 优先队列的使用 题目1873

    STL优先队列的具体描写叙述 http://blog.csdn.net/yueloveme/article/details/47106639 题目地址:http://acm.hdu.edu.cn/s ...

  6. HDU 3949 XOR(高斯消元搞基)

    HDU 3949 XOR pid=3949" target="_blank" style="">题目链接 题意:给定一些数字,问任取几个异或值第 ...

  7. Kettle学习系列之kettle的下载、安装和初步使用(windows平台下)(图文详解)

    不多说,直接上干货! kettle的下载 žKettle可以在http://kettle.pentaho.org/网站下载                   http://sourceforge.n ...

  8. Pharmaceutical的同学们都看过来,关于补码运算的复习相关内容

    虽然是全英文的课程,这次总结内容不用英文了. 一般在计算机原理中,对两个操作数进行运算会使用C作为进位的标志位,而V作为溢出的标志位. 一般我们学完计算机原理,都知道正数的原码反码补码都一样,而问题都 ...

  9. Servlet学习(一)——Servlet的生命周期、执行过程、配置

    1.什么是Servlet Servlet 运行在服务端的Java小程序,是sun公司提供一套规范(接口),用来处理客户端请求.响应给浏览器的动态资源.但servlet的实质就是java代码,通过jav ...

  10. oracle数据库的关闭

    数据库停止: shutdown normal 无新连接 等待当前会话结束 等待当前事务结束 强制检查点并关闭文件(一致性关闭) shutdown transactional 无新连接 结束当前会话 等 ...