HDU5373 The shortest problem (YY)
http://acm.hdu.edu.cn/showproblem.php?pid=5373
YY题,模拟下计算过程就好了,计算中并不要保存实际数(这个数会非常大),只要保存到目前为止的数字位上的和 与 奇偶位上的差即可
#pragma comment(linker, "/STACK:1677721600")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <bitset>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstdarg>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define inf (-((LL)1<<40))
#define root 1, 1, n
#define lc (k << 1)
#define rc (k << 1 | 1)
#define middle ((L + R) >> 1)
#define lson k<<1, L, (L + R)>>1
#define rson k<<1|1, ((L + R)>>1) + 1, R
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define mem(a, b) memset(a, b, sizeof(a))
#define FIN freopen("in.txt", "r", stdin)
#define FOUT freopen("out.txt", "w", stdout)
#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define dec(i, a, b) for(int i = a; i >= b; i --) //typedef __int64 LL;
typedef long long LL;
typedef pair<int, int> Pair;
const int MAXN = + ;
const int MAXM = ;
const double eps = 1e-10;
LL MOD = ; int n, t; //将n拆开,数字和加到sum中,奇偶差加到dif中,符号保存在f中
void calc_dif(int n, int &f, int &dif, int &sum) {
int d = , s = , pf = f;
while(n) {
s += n % ;
d += n % * f;
f = -f;
n /= ;
}
if(f == pf) d *= -;
sum += s;
dif += d;
} int main()
{
#ifndef ONLINE_JUDGE
FIN;
// FOUT;
#endif
int cas = ;
while(cin >> n >> t && (n != -)) {
int f = , dif = , sum = ;
calc_dif(n, f, dif, sum);
while(t--) calc_dif(sum, f, dif, sum);
printf("Case #%d: %s\n", ++cas, dif % ? "No" : "Yes");
}
return ;
}
HDU5373 The shortest problem (YY)的更多相关文章
- 【BZOJ3489】A simple rmq problem(KD-Tree)
[BZOJ3489]A simple rmq problem(KD-Tree) 题面 BZOJ 题解 直接做肯定不好做,首先我们知道我们是一个二维平面数点,但是限制区间只能出现一次很不好办,那么我们给 ...
- 【CF954I】Yet Another String Matching Problem(FFT)
[CF954I]Yet Another String Matching Problem(FFT) 题面 给定两个字符串\(S,T\) 求\(S\)所有长度为\(|T|\)的子串与\(T\)的距离 两个 ...
- 洛谷 P1581 A+B Problem(升级版)
P1581 A+B Problem(升级版) 题目背景 小明这在写作业,其中有一道A+B Problem ,他想啊想啊想,就是想不出来,于是就找到了会编程的你...... 题目描述 这里的A+B是很奇 ...
- nyoj 844-A+B Problem(V) (string[::-1] 字符串反转)
844-A+B Problem(V) 内存限制:64MB 时间限制:1000ms 特判: No 通过数:14 提交数:17 难度:1 题目描述: 做了A+B Problem之后,Yougth感觉太简单 ...
- Leetcode 943. Find the Shortest Superstring(DP)
题目来源:https://leetcode.com/problems/find-the-shortest-superstring/description/ 标记难度:Hard 提交次数:3/4 代码效 ...
- hdu 5373 The shortest problem(杭电多校赛第七场)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5373 The shortest problem Time Limit: 3000/1500 MS (J ...
- hdu 1016 Prime Ring Problem(DFS)
Prime Ring Problem Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- HDU 2522 A simple problem (模拟)
题目链接 Problem Description Zty很痴迷数学问题..一天,yifenfei出了个数学题想难倒他,让他回答1 / n.但Zty却回答不了^_^. 请大家编程帮助他. Input 第 ...
- A/B Problem(大数)
描述 做了A+B Problem,A/B Problem不是什么问题了吧! 输入 每组测试样例一行,首先一个号码A,中间一个或多个空格,然后一个符号( / 或者 % ),然后又是空格,后面又是一个号码 ...
随机推荐
- configparser、subprocess模块
一.configparser模块 该模块适用于配置文件的格式与windows ini文件类似,可以包含一个或多个节(section),每个节可以有多个参数(键=值). 1.创建文件 一般软件的常见文档 ...
- springboot activiti关闭验证自动部署
# spring-activiti # 自动部署验证设置:true-开启(默认).false-关闭 spring.activiti.check-process-definitions=false # ...
- spring 监听器 IntrospectorCleanupListener
org.springframework.web.util.IntrospectorCleanupListener监听器 主要负责处理由JavaBean Introspector使用而引起的缓冲泄露, ...
- sort中的比较函数compare
sort中的比较函数compare要声明为静态成员函数或全局函数,不能作为普通成员函数,否则会报错: invalid use of non-static member function 因为:非静态成 ...
- MyBatis Generator自动创建代码
MyBatis Generator自动创建代码 1.首先在eclipse上安装mybatis插件 2.创建一个mavenWeb项目. 3.在resource中写入一个xml,一定要与我得同名 < ...
- 快速SQL调优/优化(SQL TUNING)——1分钟搞定超慢SQL
前几天,一个用户的研发人员找到我了,说他们有个SQL语句非常慢,我说多慢?他们说:半个小时也没出结果.于是问他们要了SQL语句和执行计划,SQL语句就不能再这里贴出来了,下面是调整前的执行计划(略去某 ...
- js获取当前点击元素的索引
以ul下的li元素为例:获取li的索引,代码如下: <ul id="list"> <li></li> <li></li> ...
- 浅谈musql中using的使用---高性能(三)
转载地址:https://blog.csdn.net/lppl010_/article/details/79429657 mysql中using的用法为: using()用于两张表的join查询,要求 ...
- hadoop kafka install multi-borker (7)
multi-borker function like cluster technology First we make a config file for each of the brokers (o ...
- React教程-初入
学习了React很久,一直没有机会总结下,最近打算写一个简单的React,希望让初学者一看就懂,不走弯路,我尽量写的简明点好了开始吧!首页我们要利用npm安装 react(当然你也可以用引用方式)跟着 ...