对于这题笔者认为可以用数学排列来算,但是由于笔者很懒所以抄了一段大神的代码来交个大家了, 这位大神的基本想法就是通过记录各类书的数量,再暴力破解: 下面贴出这位大神的代码吧: #include<iostream> #include<cstdio> #include<algorithm> using namespace std; ]; int main() { int n,m; scanf("%d%d",&n,&m); ;i<=n…
B. Obtain Two Zeroes time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given two integers aa and bb. You may perform any number of operations on them (possibly zero). During each oper…
题目链接:http://codeforces.com/problemset/problem/505/A 题目意思:给出一个长度不大于10的小写英文字符串 s,问是否能通过在字符串的某个位置插入一个字母,使得新得到的字符串成为回文串. /**************************************(又到自我反省时刻) 做的时候,通过添加一个单位使得长度增加1,找出中点,检验前一半的位置,找出对称位置替换成对应的前一半位置的字符,然后原字符串剩下的部分追加到后面,再判断回文.但是由于…
A. On Number of Decompositions into Multipliers 题目连接:http://codeforces.com/contest/396/problem/A 大意:给定n(n<=500)个数ai(1<=ai<=10^9),得到他们的乘积m,问将m分解成n个数相乘,有多少种方法. 思路:显然每个质因数都是独立的,如果质因数pi出现了ci次,那么把它分到n个数中,就有C(ci+n-1,n-1)种方法,然后把所有因数的答案相乘就是结果.于是我们可以先预处理出…
题目链接:http://codeforces.com/problemset/problem/433/A 题目意思:给定 n 个只由100和200组成的数,问能不能分成均等的两份. 题目其实不难,要考虑清楚数量问题即可.就是说,200的数量是奇数或偶数,100的数量是奇数或偶数时的处理. 一开始可能思路有点混乱,学人3分钟打一道题,wa了3次. 由于写得比较混乱,我的代码不好意思贴出来,以下借鉴了别人的两种好的写法. Time: 31ms  Memory: 0KB #include <iostre…
题目链接:http://codeforces.com/problemset/problem/334/C 题目: 题目大意: 给定数字n,要求构建一个数列使得数列的每一个元素的值都是3的次方,数列之和S大于n,且删掉数列中的任意一个元素数列之和都会小于n,最大化这个数列的长度 题解: 我们考虑从小到大枚举k,取最小的k,使得,答案就是$n/3^k+1$ 为什么呢? 我们考虑一个合法的数列,其中最小的元素是A,那么S一定是A的倍数.假设n是A的倍数,又S>n,那么S-A>=n,这样的话去掉A这个数…
Div. 2 Multiplication Table (577A) 题意: 给定n行n列的方阵,第i行第j列的数就是i*j,问有多少个格子上的数恰为x. 1<=n<=10^5, 1<=x<=10^9 题解: 送分题…对于每一行,判断是否存在数x即可…也可以枚举x的因子判断是否出现在表内… 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 #include <cstdio> #include <cstring> inline in…
题目A: 给一个火柴等式,可以从左边移动一根到右边,也可以从右边移到左边,但是不能移动“+”,”=“的火柴, 而且加法里面的数都要大于0(很重要的条件),基本上注意到这点的都过了,没注意的都被HACK了. #include<iostream> #include<math.h> #include<algorithm> #include<;    ;    &&a!=b) cout<<;i<s.size()-;i++)        …
Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes 题目连接: http://codeforces.com/contest/985/problem/E Description Mishka received a gift of multicolored pencils for his birthday! Unfortunately he lives in a monochrome w…
[Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file for some programming competition problem. His input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually ge…