同余模定理 HDOJ 5373 The shortest problem
/*
题意:题目讲的很清楚:When n=123 and t=3 then we can get 123->1236->123612->12361215.要求t次操作后,能否被11整除
同余模定理:每次操作将后缀值加到上次操作的值%11后的后面,有点绕,纸上模拟一下就行了
*/
/************************************************
* Author :Running_Time
* Created Time :2015-8-12 8:50:23
* File Name :E.cpp
************************************************/ #include <cstdio>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <cstdlib>
#include <ctime>
using namespace std; #define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
typedef long long ll;
const int MAXN = 1e5 + ;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + ;
int a[MAXN]; int part(int x) {
int ret = ;
while (x) {
ret += x % ; x /= ;
}
return ret;
} int cal(int x) {
int ret = ;
while (x) {
ret *= ; x /= ;
}
return ret;
} int main(void) { //HDOJ 5373 The shortest problem
int n, t, cas = ;
while (scanf ("%d%d", &n, &t) == ) {
if (n == - && t == -) break; a[] = n; int sum = part (n);
for (int i=; i<=t+; ++i) {
a[i] = a[i-] % * cal (sum) + sum;
sum += part (sum);
} printf ("Case #%d: %s\n", ++cas, (a[t+] % == ) ? "Yes" : "No");
} return ;
}
同余模定理 HDOJ 5373 The shortest problem的更多相关文章
- hdoj 5373 The shortest problem
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5373 一开始想到用整除11的性质去做,即奇位数的和和偶位数的和的差为11的倍数,但估不准数据范围没敢去 ...
- hdu 5373 The shortest problem(杭电多校赛第七场)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5373 The shortest problem Time Limit: 3000/1500 MS (J ...
- 2015 Multi-University Training Contest 7 hdu 5373 The shortest problem
The shortest problem Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Oth ...
- HDU 5373 The shortest problem (数学)
题意:给定两个数的n和m,有一种操作,把 n 的各位数字加起来放到 n后面形成一个新数n,问重复 m 次所得的数能否整除 11. 析:这个题首先要知道一个规律奇数位的和减去偶数位的和能被11整除的数字 ...
- HDU-5373 The shortest problem
The shortest problem http://acm.hdu.edu.cn/showproblem.php?pid=5373 Time Limit: 3000/1500 MS (Java/O ...
- The shortest problem
The shortest problem Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others ...
- 【阔别许久的博】【我要开始攻数学和几何啦】【高精度取模+同余模定理,*】POJ 2365 The Embarrassed Cryptographer
题意:给出一大数K(4 <= K <= 10^100)与一整数L(2 <= L <= 106),K为两个素数的乘积(The cryptographic keys are cre ...
- The Embarrassed Cryptographer(高精度取模+同余模定理)
Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 11435 Accepted: 3040 Description The ...
- POJ - 1426 暴力枚举+同余模定理 [kuangbin带你飞]专题一
完全想不到啊,同余模定理没学过啊,想起上学期期末考试我问好多同学'≡'这个符号什么意思,都说不知道,你们不是上了离散可的吗?不过看了别人的解法我现在会了,同余模定理介绍及运用点这里点击打开链接 简单说 ...
随机推荐
- MVC Ajax.BeginForm重复提交解决方法
mvc使用MVC Ajax.BeginForm提交的时候有重复提交结果的时候检查相关js文件引用情况, 其中mvc4注意 1 2 3 4 @Scripts.Render("~/bundles ...
- 【HDOJ6118】度度熊的交易计划(费用流)
题意: 度度熊参与了喵哈哈村的商业大会,但是这次商业大会遇到了一个难题: 喵哈哈村以及周围的村庄可以看做是一共由n个片区,m条公路组成的地区. 由于生产能力的区别,第i个片区能够花费a[i]元生产1个 ...
- Linux下汇编语言学习笔记0 --- 前期准备工作
这是17年暑假学习Linux汇编语言的笔记记录,参考书目为清华大学出版社 Jeff Duntemann著 梁晓辉译<汇编语言基于Linux环境>的书,喜欢看原版书的同学可以看<Ass ...
- Codeforces 629D Babaei and Birthday Cake(线段树优化dp)
题意: n个蛋糕编号从小到大编号,j号蛋糕可以放在i号上面,当且仅当j的体积严格大于i且i<j,问最终可得的最大蛋糕体积. 分析: 实质为求最长上升子序列问题,设dp[i]从头开始到第i位的最长 ...
- CODEFORCES problem 105A.Transmigration
题目本身上手并不难,字符串处理+简单的排序.要注意的地方是浮点数的处理. 依据计算机中浮点数的表示原理,在实际编程的过程中即使用一个确定的整数(假设是1)给一个浮点变量赋值 在查看变量时会发现实际存储 ...
- c内存分配(转)
图示 C内存分配 程序代码区 存放函数体的二进制代码 全局数据区 全局变量和静态变量的存储是放在一起的.初始化的全局变量和静态变量在一块区域,未初始化的全局变量和未初始化的静态变量在相邻的另一块区域. ...
- 如何探测浏览器是否开启js功能
<body> ... ... <script type="text/javascript"> <!-- document.write("He ...
- ppc_85xx-gcc -shared -fPIC liberr.c -o liberr.so
fPIC作用于编译阶段,告诉编译器产生与位置无关代码(Position-Independent Code), 则产生的代码中,没有绝对地址,所有使用相对地址.故而代码能够被载入器载入到内存的随意 ...
- [python]pycharm画图插件matplotlib、numpy、scipy的下载与安装
最近在用pycharm学习python语言,不得不感叹python语言的强大与人性化! 但对于使用pycharm画图(较复杂的图)就要用到几个插件了,即matplotlib.numpy和scipy!但 ...
- paramiko_su_root
#coding=utf8 import paramiko import time import logging ''' if user root,can not login,must use user ...