codeforces584B Kolya and Tanya】的更多相关文章

题目链接:http://codeforces.com/problemset/problem/584/B 解题思路:当n=1时,_______    _______   ______  三个数每位上可以填1,2,3三个数,所以,所有可能的结果就是3*3*3   不满足条件的有2 2 2这一种情况,还有1 2 3这三个数字,总共有6种情况,所以答案是27-1-6=20:当n=2时,所有可能的结果是3*3*3*3*3*3-?=680 ,可以推测出减去49即7*7 所以找到的规律就是: 当n=1时,  …
B. Kolya and Tanya Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/584/problem/B Description Kolya loves putting gnomes at the circle table and giving them coins, and Tanya loves studying triplets of gnomes, sitting in the v…
题目大意:3n个人围着一张桌子,给每个人发钱,可以使1块.2块.3块,第i个人的金额为Ai.若存在第个人使得Ai + Ai+n + Ai+2n != 6,则该分配方案满足条件,求所有的满足条件的方案数 结果 MOD 1000000007. 解题思路:当 n = 1 时有总共有27中情况,其中20中满足条件,则 (27^n - 7^n)为所求结果. 代码 #include<iostream> #include<cstdio> #include<cstdlib> using…
原题链接:http://codeforces.com/contest/584/problem/B 题意: 有3*n个人围成一个圈,每个人可以分配1到3个硬币,但是相邻为n的三个人的和不能是6,问你有多少种方案 题解: 考虑反面,则答案是: $$27^n-(3!+1)^n$$ 代码: #include<iostream> #include<cstring> #include<cstdio> using namespace std; typedef long long LL…
---恢复内容开始--- Codeforces Round #324 (Div. 2) Problem A 题目大意:给二个数n.t,求一个n位数能够被t整除,存在多组解时输出任意一组,不存在时输出“-1”. 数据范围: 1 ≤ n ≤ 100, 2 ≤ t ≤ 10 so easy!首先考虑无解的时候,只有当n==1,t==10是无解,其他情况都存在解.很容易想到最简单的n位数能被t整除的数是,t个n组成的数. 参考代码: By Royecode, contest: Codeforces Ro…
链接:https://codeforces.com/contest/584 A - Olesya and Rodion - [水] 题解:注意到 $t$ 的范围是 $[2,10]$,对于位数小于 $2 \times 3 \times \cdots \times 10 = 3628800$ 的数,暴力枚举去找:否则就直接在 $3628800$ 后面补零即可. AC代码: #include<bits/stdc++.h> using namespace std; int n,t; ]; int ma…
B. Kolya and Tanya time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Kolya loves putting gnomes at the circle table and giving them coins, and Tanya loves studying triplets of gnomes, sitting…
CF的rating设置改了..人太多了,决定开小号打,果然是明智的选择! 水 A - Olesya and Rodion #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e5 + 10; const int INF = 0x3f3f3f3f; int main(void) { int n, t; scanf ("%d%d", &n, &t);…
B. Tanya and Postcard time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little Tanya decided to present her dad a postcard on his Birthday. She has already created a message — string s of le…
题目链接:http://codeforces.com/problemset/problem/518/B 题目意思:给出字符串 s 和 t,如果 t 中有跟 s 完全相同的字母,数量等于或者多过 s,就将 s 这个数量加到 YAY! 的答案里,少于的话就加 t 中有的数量:如果 t 中有跟 s 相同的字母但是大小写不对应(例如A-a,z-Z),就加到 WHOOPS 的答案里. 举个例子就很容易明白了.例如 s 和 t 分别为: ncMeXssLHS uwyeMcaFatpInZVdEYpwJQSn…
D. Tanya and Password Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/508/problem/D Description While dad was at work, a little girl Tanya decided to play with dad's password to his secret database. Dad's password is a stri…
Kolya got string s for his birthday, the string consists of small English letters. He immediately added k more characters to the right of the string. Then Borya came and said that the new string contained a tandem repeat of length l as a substring. H…
Tanya and Postcard time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little Tanya decided to present her dad a postcard on his Birthday. She has already created a message — string s of lengt…
B. Kolya and Tandem Repeat time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Kolya got string s for his birthday, the string consists of small English letters. He immediately added k more ch…
Description While dad was at work, a little girl Tanya decided to play with dad characters. She has written all the possible n three-letter continuous substrings of the password on pieces of paper, one for each piece of paper, and threw the password…
纯粹练JAVA.... B. Kolya and Tandem Repeat time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Kolya got string s for his birthday, the string consists of small English letters. He immediately add…
C. Tanya and Toys 题目链接http://codeforces.com/contest/659/problem/C Description In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collectio…
Description In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1to 109. A toy from the new collection of the i-th type costs i bourles. Tania has managed to collect n …
B. Our Tanya is Crying Out Loud time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Right now she actually isn't. But she will be, if you don't solve this problem. You are given integers n, k, A an…
Tanya and Candies time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Tanya has nn candies numbered from 11 to nn . The ii -th candy has the weight aiai . She plans to eat exactly n−1n−1 candie…
Tanya has nn candies numbered from 11 to nn. The ii-th candy has the weight aiai. She plans to eat exactly n−1n−1 candies and give the remaining candy to her dad. Tanya eats candies in order of increasing their numbers, exactly one candy per day. You…
B. Tanya and Postcard time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little Tanya decided to present her dad a postcard on his Birthday. She has already created a message — string s of le…
C. Tanya and Toys 题目连接: http://www.codeforces.com/contest/659/problem/C Description In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new col…
Little girl Tanya climbs the stairs inside a multi-storey building. Every time Tanya climbs a stairway, she starts counting steps from 1 to the number of steps in this stairway. She speaks every number aloud. For example, if she climbs two stairways,…
C. Tanya and Toys time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with int…
B. Our Tanya is Crying Out Loud time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Right now she actually isn't. But she will be, if you don't solve this problem. You are given integers n, k,…
题目链接: C. Tanya and Toys time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered wi…
 Kolya and Tandem Repeat time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Kolya got string s for his birthday, the string consists of small English letters. He immediately added k more ch…
Our Tanya is Crying Out Loud time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Right now she actually isn't. But she will be, if you don't solve this problem. You are given integers n, k, A a…
本题要考虑字符串本身就存在tandem, 如测试用例 aaaaaaaaabbb 3 输出结果应该是8而不是6,因为字符串本身的tanderm时最长的 故要考虑字符串本身的最大的tanderm和添加k个字符后最大的tanderm #include <iostream> #include <vector> #include <algorithm> #include <string> #include <set> using namespace std…