C. Long Beautiful Integer】的更多相关文章

链接: https://codeforces.com/contest/1269/problem/C 题意: You are given an integer x of n digits a1,a2,-,an, which make up its decimal notation in order from left to right. Also, you are given a positive integer k<n. Let's call integer b1,b2,-,bm beautif…
题目思路还是很直接,首先按要求生成字符串.如果该目标字符串小于原字符串,那么从第k位开始,找到最后一个非9的位置,++,同时如果有9,要考虑进位(一开始没有考虑WA了一次). 犯了一个错误,就是比较字符串大小时,一开始写的是如果b中有一个小于a,就return false.WA了半天.可以直接用strcmp(). #include <bits/stdc++.h> using namespace std; ; int n,k; char a[N],b[N]; bool check() { ;i&…
题解: 这里的m一定是等于n的,n为数最大为n个9,这n个9一定满足条件,根据题目意思,前k个一定是和原序列前k个相等,因此如果说我们构造出来的大于等于原序列,直接输出就可以了,否则,由于后m-k个一定是重复前k个,我们只能在前k个改动,所以只需要让前k个加1就行了,然后在根据题意构造一遍. #include<bits/stdc++.h> using namespace std; ; char s[N],s1[N]; void solve() { int n,k; cin>>n&g…
Equation Modulo Equality Long Beautiful Integer Domino for Young K Integers Equation \[ Time Limit: 3 s\quad Memory Limit: 256 MB \] 这题做法很多,甚至可以直接暴力判断 view #include <map> #include <set> #include <list> #include <ctime> #include <…
Codeforces Round #609 (Div. 2)前五题题解 补题补题…… C题写挂了好几个次,最后一题看了好久题解才懂……我太迟钝了…… 然后因为longlong调了半个小时…… A.Equation 题目大意:有一个数字n,让你给出任意两个合数a,b满足a - b = n. 我们知道大于2的偶数都是合数,那么如果n为奇数,只要n加上一个奇数合数一定也为合数,如果n为偶数,那么n加上一个偶数合数也一定为合数. 因为只求任意一组,就直接选择4,9,若为奇数输出 +n 和9,偶数输出 +…
contest链接:https://codeforces.com/contest/1269 A. Equation 题意:输入一个整数,找到一个a,一个b,使得a-b=n,切a,b都是合数 思路:合数非常多,从1开始枚举b,a就是b+n,每次check一下a,b是否是合数,是的话直接输出,break即可 AC代码: #include<iostream> #include<string> #include<vector> #include<cstring> #…
hihoCoder #1425 : What a Beautiful Lake(美丽滴湖) 时间限制:1000ms 单点时限:1000ms 内存限制:256MB Description - 题目描述 Weiming Lake, also named "Un-named Lake", is the most famous scenic spot in Peking University. It is located in the north of the campus and is su…
hdu4888 Redraw Beautiful Drawings Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 2007    Accepted Submission(s): 447 Problem Description Alice and Bob are playing together. Alice is crazy abou…
D. Beautiful numbers time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if…
[codeforces 55]D. Beautiful numbers 试题描述 Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if and only if it is divisible by each of its nonzero digits. We will not argue with this and…