• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

cynchanpin

  • 博客园
  • 联系
  • 订阅
  • 管理

View Post

HDU 5373(2015多校7)-The shortest problem(模拟%11)

题目地址: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;
}

posted on 2017-06-17 11:47  cynchanpin  阅读(188)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3