同余模定理 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带你飞]专题一
完全想不到啊,同余模定理没学过啊,想起上学期期末考试我问好多同学'≡'这个符号什么意思,都说不知道,你们不是上了离散可的吗?不过看了别人的解法我现在会了,同余模定理介绍及运用点这里点击打开链接 简单说 ...
随机推荐
- XMLREADER/DOM/SIMPLEXML 解析大文件
DOM和simplexml处理xml非常的灵活方便,它们的内存组织结构与xml文件格式很相近.但是同时它们也有一个缺点,对于大文件处理起来力不从心,太耗内存了. 还好有xmlreader,基于流的解析 ...
- Linux中kill,pkill,killall和xkill命令汇总讲解
终止一个进程或终止一个正在运行的程式,一般是通过 kill .killall.pkill.xkill 等进行.比如一个程式已死掉,但又不能退出,这时就应该考虑应用这些工具. 另 外应用的场合就是在服务 ...
- TCP/IP学习笔记(3)----IP,ARP,RARP协议
把这三个协议放到一起学习是因为这三个协议处于同一层(网络层协议),ARP协议用来找到目标主机的Ethernet网卡Mac地址,IP则承载要发送的消息.数据链路层可以从ARP得到数据的传送信息,而从IP ...
- Java开发笔记(九十九)定时器与定时任务
前面介绍了线程的几种运行方式,不管哪种方式,一旦调用了线程实例的start方法,都会立即启动线程的事务处理.然而某些业务场景在事务执行时间方面有特殊需求,例如期望延迟若干时间之后才开始事务运行,又如期 ...
- Linux下tomcat的catalina.out屏蔽
修改catalina.sh ,找到下面的位置: if [ -z "$CATALINA_OUT" ] ; then#CATALINA_OUT="$CATALINA_BASE ...
- Mac 系统引导过程概述 & BootCamp 的秘密
http://bbs.feng.com/read-htm-tid-6890655.html
- 关于python内存管理里的引用计数算法和标记-清楚算法的讨论
先记录于此,后续有时间再深究吧: 1.https://www.zhihu.com/question/33529443 2.http://patshaughnessy.net/2013/10/30/ge ...
- 012 router password
Press RETURN to get started! Router>en Router#config t Enter configuration commands, one pe ...
- STM32F104VG (一)中断与外部中断
一.基础知识 1.ARM的中断优先级分硬件优先级和软件优先级两种 当中软件优先级又由抢占优先级和响应优先级组成 2.中断的优先级採用编号小优先的原则. 3.普通情况: 1).假设设定了软件优先级.先看 ...
- Linux改动/etc/profile配置错误command is not found自救方法
我的CSDN博客地址: http://blog.csdn.net/caicongyang 博主之前在改动了/etc/profile配置文件方法后,导致bash命令无法用 运行ls命令结果例如以下: - ...