The shortest problem

Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 346    Accepted Submission(s): 167

Problem Description
In this problem, we should solve an interesting game. At first, we have an integer n, then we begin to make some funny change. We sum up every digit of the n, then insert it to the tail of the number n, then let the new number be the interesting number n. repeat it for t times. When n=123 and t=3 then we can get 123->1236->123612->12361215.
 
Input
Multiple input.
We have two integer n (0<=n<=104 ) , t(0<=t<=105) in each row.
When n==-1 and t==-1 mean the end of input.
 
Output
For each input , if the final number are divisible by 11, output “Yes”, else output ”No”. without quote.
 
Sample Input
35 2
35 1
-1 -1
 
Sample Output
Case #1: Yes
Case #2: No
 
Source
 
解题:由于能被11整除的数的特点是奇数位与偶数位的和的绝对值可以被11整除,所以,搞一下就可以了
 
 #include <bits/stdc++.h>
using namespace std;
int cur = ,n,m,d[];
int solve(int x) {
int a[] = {};
cur = ;
while(x) {
a[cur^] += x%;
x /= ;
cur ^= ;
}
if(cur&) swap(d[],d[]);
d[] += a[];
d[] += a[];
return d[] + d[];
}
int main() {
int cs = ;
while(scanf("%d%d",&n,&m),(~n) && (~m)) {
d[] = d[] = ;
for(int i = ; i <= m; ++i) n = solve(n);
printf("Case #%d: %s\n",cs++,abs(d[]-d[])%?"No":"Yes");
}
return ;
}

2015 Multi-University Training Contest 7 hdu 5373 The shortest problem的更多相关文章

  1. hdu 5373 The shortest problem(杭电多校赛第七场)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5373 The shortest problem Time Limit: 3000/1500 MS (J ...

  2. 2015 Multi-University Training Contest 7 hdu 5371 Hotaru's problem

    Hotaru's problem Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  3. HDU 5373 The shortest problem (数学)

    题意:给定两个数的n和m,有一种操作,把 n 的各位数字加起来放到 n后面形成一个新数n,问重复 m 次所得的数能否整除 11. 析:这个题首先要知道一个规律奇数位的和减去偶数位的和能被11整除的数字 ...

  4. 2019 Multi-University Training Contest 2: 1010 Just Skip The Problem 自闭记

    2019 Multi-University Training Contest 2: 1010 Just Skip The Problem 自闭记 题意 多测.每次给你一个数\(n\),你可以同时问无数 ...

  5. 同余模定理 HDOJ 5373 The shortest problem

    题目传送门 /* 题意:题目讲的很清楚:When n=123 and t=3 then we can get 123->1236->123612->12361215.要求t次操作后, ...

  6. 2015 Multi-University Training Contest 8 hdu 5390 tree

    tree Time Limit: 8000ms Memory Limit: 262144KB This problem will be judged on HDU. Original ID: 5390 ...

  7. 2015 Multi-University Training Contest 8 hdu 5383 Yu-Gi-Oh!

    Yu-Gi-Oh! Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on HDU. Original ID:  ...

  8. 2015 Multi-University Training Contest 8 hdu 5385 The path

    The path Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on HDU. Original ID: 5 ...

  9. 2015 Multi-University Training Contest 3 hdu 5324 Boring Class

    Boring Class Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tota ...

随机推荐

  1. SSH框架整合截图(二)

    客户拜访管理 1 什么是客户拜访 (1)客户:与公司有业务往来的 (2)用户:可以使用系统的人 2 用户和客户关系 (1)用户和客户之间是拜访的关系 (2)用户 和 客户 是 多对多关系 ** 一个用 ...

  2. 工具-NuGet

    1.添加下载后,会将文件添加到当前项目的引用和bin目录中 ORM是一种插件/组件,将对集合对象的操作映射为对关系型数据库的操作,这个映射是相互的 来自为知笔记(Wiz)

  3. Oracle里schema理解

    在Oracle中,一个用户就是一个Schema,表都是建立在Schema中的,也可以理解为每个用户拥有不同的表.一个用户想访问另外一个用户,也就是另外一个schema的表的时候,可以用 usernam ...

  4. Java Pattern Matcher 正则表达式需要转义的字符

    见:http://blog.csdn.net/bbirdsky/article/details/45368709 /** * 转义正则特殊字符 ($()*+.[]?\^{},|) * * @param ...

  5. HDU 4349

    想了好久,没思路.看别人说是卢卡斯,就去看卢卡斯了,看完卢卡斯,再用它推导一下,很容易就知道,答案是2^n的二进制中一的个数.改天找个时间写个卢卡斯的总结.~~~今晚竟然要上形势政治课,靠.... # ...

  6. 嵌入式linux和pc机的linux对照

    linux本身具备的非常大长处就是稳定,内核精悍,执行时须要的资源少.嵌入式linux和普通linux并无本质差别. 在嵌入式系统上执行linux的一个缺点就是其核心架构没有又一次设计过,而是直接从桌 ...

  7. DB-MySQL:MySQL 连接的使用

    ylbtech-DB-MySQL:MySQL 连接的使用 1.返回顶部 1. Mysql 连接的使用 在前几章节中,我们已经学会了如何在一张表中读取数据,这是相对简单的,但是在真正的应用中经常需要从多 ...

  8. WCF:目录

    ylbtech-WCF:目录 1.返回顶部   2.返回顶部   3.返回顶部   4.返回顶部   5.返回顶部     6.返回顶部   作者:ylbtech出处:http://ylbtech.c ...

  9. angular4父组件向子组件传值,子组件向父组件传值的方法

    父组件向子组件传值   @Input 文件目录 父组件: father.template.html <h1>父组件</h1> <cmt-child [data]='dat ...

  10. Noip蒟蒻专用模板

    目录 模板 数论 线性筛素数 线性筛欧拉 裴蜀定理 卢卡斯定理 矩阵快速幂 逆元 高斯消元 图论 割点 最小生成树 倍增 SPFA 负环 堆优化迪杰斯特拉 匈牙利 数据结构 树状数组 ST表 线段树 ...