HDU 5373(2015多校7)-The shortest problem(模拟%11)
2024-08-30 07:34:51
题目地址: pid=5373">HDU 5373
题意:给你一个数n和操作次数t,每次操作将n的各位数之和求出来放在n的末尾形成新的n,问t次操作后得到的n能否够被11整除。
思路:就是简单的模拟一下乱搞。额,对于%11有一个性质,当一个数的奇数位之和与偶数位之和的差的绝对值能被11整除,那么该数就能够被11整除。
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <map>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
typedef __int64 LL;
const int inf=0x3f3f3f3f;
const double pi= acos(-1.0);
const double esp=1e-7;
const int maxn=2*1e6+10;
LL k;
LL tail;
LL get(LL x)
{
LL cnt=1;
LL y=x;
while(x){
tail+=x%10;
x/=10;
cnt*=10;
}
k=(k*cnt+y)%11;
}
int main()
{
LL n,t;
int icase=1;
while(~scanf("%lld %lld",&n,&t)){
if(n==-1&&t==-1) break;
k=0,tail=0;
get(n);
while(t--)
get(tail);
if(!k) printf("Case #%d: Yes\n",icase++);
else printf("Case #%d: No\n",icase++);
}
return 0;
}
最新文章
- JavaScript鼠标经过图片的放大镜效果
- git 中关于LF 和 CRLF 的问题
- WWDC 2013 Session笔记 - UIKit Dynamics入门
- 图片上传iOS
- Apache httpd.conf的翻译
- js秒数转换时分秒方法
- lambda 3
- 理解 Git
- python中Django 使用方法简述
- Pyhon之Django中的Form组件
- 计算机组装:台式机更换CPU
- 《11招玩转网络安全》之第五招:DVWA命令注入
- go关键字之type用法
- 《DSP using MATLAB》Problem 7.3
- <;target>;.ID 和 <;source>;.ID 的属性冲突: DataType 属性不匹配
- AbelSu玩Kotlin
- css基础 -文本溢出 text-overflow:ellipsis;
- ios开发之--VC的生命周期
- Microsoft 数据访问组件 (MDAC) 的版本历史记录
- Spring Boot 应用系列 5 -- Spring Boot 2 整合logback