07 2017 档案
摘要:描述 Koch Snowflake is one of the most famous factal. It is built by starting with an equilateral triangle, removing the inner third of each side, build
阅读全文
摘要:老潘,袁少,小艾都是江理的大个子,他们想按身高排队,现在给你他们的身高,请你算出队伍中站在第二的有多高。 老潘,袁少,小艾都是江理的大个子,他们想按身高排队,现在给你他们的身高,请你算出队伍中站在第二的有多高。 输入三个整数,分别表示三个人的身高。(单位:纳米) 输入三个整数,分别表示三个人的身高。
阅读全文
摘要:豆豆非常调皮,总喜欢把一样的东西摆在一起,然后用神奇的猫爪功把他们揉成一团。 比如一堆A,就会被揉成个数+A. 这就是豆豆的字符串压缩算法了。 比如给豆豆一个字符串:ABBCCCDDDDEEEEEEEEEEEccc,就会被他用猫爪功压缩成1A2B3C4D11E3c 豆豆非常调皮,总喜欢把一样的东西摆
阅读全文
摘要:Yaroslav has an array that consists of n integers. In one second Yaroslav can swap two neighboring array elements. Now Yaroslav is wondering if he can
阅读全文
摘要:Shaass has decided to hunt some birds. There are n horizontal electricity wires aligned parallel to each other. Wires are numbered 1 to nfrom top to b
阅读全文
摘要:In the city of Ultima Thule job applicants are often offered an IQ test. The test is as follows: the person gets a piece of squared paper with a 4 × 4
阅读全文
摘要:1 #include <iostream> 2 #include <algorithm> 3 #include <cstring> 4 #include <cstdio> 5 #include <vector> 6 #include <cstdlib> 7 #include <iomanip> 8
阅读全文
摘要:A few years ago, Hitagi encountered a giant crab, who stole the whole of her body weight. Ever since, she tried to avoid contact with others, for fear
阅读全文
摘要:Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of e
阅读全文
摘要:Bear Limak wants to become the largest of bears, or at least to become larger than his brother Bob. Right now, Limak and Bob weigh a and b respectivel
阅读全文
摘要:Emuskald needs a fence around his farm, but he is too lazy to build it himself. So he purchased a fence-building robot. He wants the fence to be a reg
阅读全文
摘要:Two players play a simple game. Each player is provided with a box with balls. First player's box contains exactly n1 balls and second player's box co
阅读全文
摘要:Ted has a pineapple. This pineapple is able to bark like a bulldog! At time t (in seconds) it barks for the first time. Then every s seconds after it,
阅读全文
摘要:Walking through the streets of Marshmallow City, Slastyona have spotted some merchants selling a kind of useless toy which is very popular nowadays –
阅读全文
摘要:小K手中有n张牌,每张牌上有一个一位数的数,这个字数不是0就是5。小K从这些牌在抽出任意张(不能抽0张),排成一行这样就组成了一个数。使得这个数尽可能大,而且可以被90整除。 注意: 1.这个数没有前导0, 2.小K不需要使用所有的牌。 小K手中有n张牌,每张牌上有一个一位数的数,这个字数不是0就是
阅读全文
摘要:给出2个大整数A,B,计算A+B的结果。 给出2个大整数A,B,计算A+B的结果。 给出2个大整数A,B,计算A+B的结果。 Input 第1行:大数A 第2行:大数B (A,B的长度 <= 10000 需注意:A B有可能为负数) Output 输出A + B Input示例 6893214758
阅读全文
摘要:对正整数n,欧拉函数是少于或等于n的数中与n互质的数的数目。此函数以其首名研究者欧拉命名,它又称为Euler's totient function、φ函数、欧拉商数等。例如:φ(8) = 4(Phi(8) = 4),因为1,3,5,7均和8互质。 对正整数n,欧拉函数是少于或等于n的数中与n互质的数
阅读全文
摘要:现在有好多种砝码,他们的重量是 w0,w1,w2,... 每种各一个。问用这些砝码能不能表示一个重量为m的东西。 样例解释:可以将重物和3放到一个托盘中,9和1放到另外一个托盘中。 现在有好多种砝码,他们的重量是 w0,w1,w2,... 每种各一个。问用这些砝码能不能表示一个重量为m的东西。 样例
阅读全文
摘要:Pashmak has fallen in love with an attractive girl called Parmida since one year ago... Today, Pashmak set up a meeting with his partner in a romantic
阅读全文
摘要:Recently Anton found a box with digits in his room. There are k2 digits 2, k3 digits 3, k5 digits 5 and k6 digits 6. Anton's favorite integers are 32
阅读全文
摘要:Someday, Drazil wanted to go on date with Varda. Drazil and Varda live on Cartesian plane. Drazil's home is located in point (0, 0) and Varda's home i
阅读全文
摘要:A and B are preparing themselves for programming contests. To train their logical thinking and solve problems better, A and B decided to play chess. D
阅读全文
摘要:Our good friend Mole is trying to code a big message. He is typing on an unusual keyboard with characters arranged in following way: qwertyuiopasdfghj
阅读全文
摘要:What joy! Petya's parents went on a business trip for the whole year and the playful kid is left all by himself. Petya got absolutely happy. He jumped
阅读全文
摘要:So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet
阅读全文
摘要:Simon and Antisimon play a game. Initially each player receives one fixed positive integer that doesn't change throughout the game. Simon receives num
阅读全文
摘要:Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given n numbers differs from the others. Bob obs
阅读全文
摘要:Little Chris is bored during his physics lessons (too easy), so he has built a toy box to keep himself occupied. The box is special, since it has the
阅读全文
摘要:Polycarp has just invented a new binary protocol for data transmission. He is encoding positive integer decimal number to binary string using followin
阅读全文
摘要:Kirito is stuck on a level of the MMORPG he is playing now. To move on in the game, he's got to defeat all n dragons that live on this level. Kirito a
阅读全文
摘要:Duff is addicted to meat! Malek wants to keep her happy for n days. In order to be happy in i-th day, she needs to eat exactly ai kilograms of meat. T
阅读全文
摘要:A - ABCxxx Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement This contest, AtCoder Beginner Contest, is abbreviated as ABC
阅读全文
摘要:给出一个整数N,将N表示为2个整数i j的平方和(i <= j),如果有多种表示,按照i的递增序输出。 例如:N = 130,130 = 3^2 + 11^2 = 7^2 + 9^2 (注:3 11同11 3算1种) 给出一个整数N,将N表示为2个整数i j的平方和(i <= j),如果有多种表示,
阅读全文
摘要:一个N*N矩阵中有不同的正整数,经过这个格子,就能获得相应价值的奖励,从左上走到右下,只能向下向右走,求能够获得的最大价值。 例如:3 * 3的方格。 1 3 3 2 1 3 2 2 1 能够获得的最大价值为:11。 一个N*N矩阵中有不同的正整数,经过这个格子,就能获得相应价值的奖励,从左上走到右
阅读全文
摘要:有一堆石子共有N个。A B两个人轮流拿,A先拿。每次拿的数量只能是2的正整数次幂,比如(1,2,4,8,16....),拿到最后1颗石子的人获胜。假设A B都非常聪明,拿石子的过程中不会出现失误。给出N,问最后谁能赢得比赛。 例如N = 3。A只能拿1颗或2颗,所以B可以拿到最后1颗石子。(输入的N
阅读全文
摘要:有一堆石子共有N个。A B两个人轮流拿,A先拿。每次最少拿1颗,最多拿K颗,拿到最后1颗石子的人获胜。假设A B都非常聪明,拿石子的过程中不会出现失误。给出N和K,问最后谁能赢得比赛。 例如N = 3,K = 2。无论A如何拿,B都可以拿到最后1颗石子。 有一堆石子共有N个。A B两个人轮流拿,A先
阅读全文
摘要:一个高度为N的由正整数组成的三角形,从上走到下,求经过的数字和的最大值。 每次只能走到下一层相邻的数上,例如从第3层的6向下走,只能走到第4层的2或9上。 5 8 4 3 6 9 7 2 9 5 例子中的最优方案是:5 + 8 + 6 + 9 = 28 一个高度为N的由正整数组成的三角形,从上走到下
阅读全文
摘要:X轴上有N条线段,每条线段包括1个起点和终点。线段的重叠是这样来算的,[10 20]和[12 25]的重叠部分为[12 20]。 给出N条线段的起点和终点,从中选出2条线段,这两条线段的重叠部分是最长的。输出这个最长的距离。如果没有重叠,输出0。 X轴上有N条线段,每条线段包括1个起点和终点。线段的
阅读全文
摘要:有编号1-n的n个格子,机器人从1号格子顺序向后走,一直走到n号格子,并需要从n号格子走出去。机器人有一个初始能量,每个格子对应一个整数A[i],表示这个格子的能量值。如果A[i] > 0,机器人走到这个格子能够获取A[i]个能量,如果A[i] < 0,走到这个格子需要消耗相应的能量,如果机器人的能
阅读全文
摘要:约翰认为字符串的完美度等于它里面所有字母的完美度之和。每个字母的完美度可以由你来分配,不同字母的完美度不同,分别对应一个1-26之间的整数。 约翰不在乎字母大小写。(也就是说字母F和f)的完美度相同。给定一个字符串,输出它的最大可能的完美度。例如:dad,你可以将26分配给d,25分配给a,这样整个
阅读全文
摘要:Olesya loves numbers consisting of n digits, and Rodion only likes numbers that are divisible by t. Find some number that satisfies both of them. Your
阅读全文
摘要:All cities of Lineland are located on the Ox coordinate axis. Thus, each city is associated with its position xi — a coordinate on the Ox axis. No two
阅读全文
摘要:n个人,已知每个人体重。独木舟承重固定,每只独木舟最多坐两个人,可以坐一个人或者两个人。显然要求总重量不超过独木舟承重,假设每个人体重也不超过独木舟承重,问最少需要几只独木舟? n个人,已知每个人体重。独木舟承重固定,每只独木舟最多坐两个人,可以坐一个人或者两个人。显然要求总重量不超过独木舟承重,假
阅读全文
摘要:A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to
阅读全文
摘要:The well-known Fibonacci sequence is defined as following: F(0) = F(1) = 1 F(n) = F(n − 1) + F(n − 2) ∀n ≥ 2 Here we regard n as the index of the Fibo
阅读全文
摘要:Recently your team noticed that the computer you use to practice for programming contests is not good enough anymore. Therefore, you decide to buy a n
阅读全文
摘要:在2*N的一个长方形方格中,用一个1*2的骨牌排满方格。 问有多少种不同的排列方法。 例如:2 * 3的方格,共有3种不同的排法。(由于方案的数量巨大,只输出 Mod 10^9 + 7 的结果) 在2*N的一个长方形方格中,用一个1*2的骨牌排满方格。 问有多少种不同的排列方法。 例如:2 * 3的
阅读全文
摘要:There are n pictures delivered for the new exhibition. The i-th painting has beauty ai. We know that a visitor becomes happy every time he passes from
阅读全文
摘要:A square number is an integer number whose square root is also an integer. For example 1, 4, 81 are some square numbers. Given two numbers a and b you
阅读全文
摘要:Solve the equation: p ∗ e −x + q ∗ sin(x) + r ∗ cos(x) + s ∗ tan(x) + t ∗ x 2 + u = 0 where 0 ≤ x ≤ 1. Input Input consists of multiple test cases and
阅读全文
摘要:A palindrome is a word, number, or phrase that reads the same forwards as backwards. For example, the name “anna” is a palindrome. Numbers can also be
阅读全文
摘要:It has been said that a watch that is stopped keeps better time than one that loses 1 second per day. The one that is stopped reads the correct time t
阅读全文
摘要:Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn them as soon as possible. There are n watchmen on a
阅读全文
摘要:The Robot Moving Institute is using a robot in their local store to transport different items. Of course the robot should spend only the minimum time
阅读全文
摘要:There is an old stone game.At the beginning of the game the player picks n(1<=n<=50000) piles of stones in a line. The goal is to merge the stones in
阅读全文
摘要:Ivan is fond of collecting. Unlike other people who collect post stamps, coins or other material stuff, he collects software bugs. When Ivan gets a ne
阅读全文
摘要:湫湫减肥 越减越肥! 最近,减肥失败的湫湫为发泄心中郁闷,在玩一个消灭免子的游戏。 游戏规则很简单,用箭杀死免子即可。 箭是一种消耗品,已知有M种不同类型的箭可以选择,并且每种箭都会对兔子造成伤害,对应的伤害值分别为Di(1 <= i <= M),每种箭需要一定的QQ币购买。 假设每种箭只能使用一次
阅读全文
摘要:Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th
阅读全文
摘要:It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch. Marmot brought Mole n ordered piles of worms such that i-th pile co
阅读全文
摘要:Let's consider a table consisting of n rows and n columns. The cell located at the intersection of i-th row and j-th column contains numberi × j. The
阅读全文
摘要:Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to pl
阅读全文
摘要:Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned
阅读全文
摘要:It's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day he invents some game and plays in it alone or with
阅读全文
摘要:给出2个N * N的矩阵M1和M2,输出2个矩阵相乘后的结果。 给出2个N * N的矩阵M1和M2,输出2个矩阵相乘后的结果。 Input 第1行:1个数N,表示矩阵的大小(2 <= N <= 100) 第2 - N + 1行,每行N个数,对应M1的1行(0 <= M1[i] <= 1000) 第N
阅读全文
摘要:M * N的方格,一个机器人从左上走到右下,只能向右或向下走。有多少种不同的走法?由于方法数量可能很大,只需要输出Mod 10^9 + 7的结果。 M * N的方格,一个机器人从左上走到右下,只能向右或向下走。有多少种不同的走法?由于方法数量可能很大,只需要输出Mod 10^9 + 7的结果。 M
阅读全文
摘要:一个正整数,如果它能被7整除,或者它的十进制表示法中某个位数上的数字为7,则称其为与7相关的数。求所有小于等于N的与7无关的正整数的平方和。 例如:N = 8,<= 8与7无关的数包括:1 2 3 4 5 6 8,平方和为:155。 一个正整数,如果它能被7整除,或者它的十进制表示法中某个位数上的数
阅读全文
摘要:水仙花数是指一个 n 位数 ( n >= 3 ),它的每个位上的数字的 n 次幂之和等于它本身。(例如:1^3 + 5^3 + 3^3 = 153) 给出一个整数M,求 >= M的最小的水仙花数。 水仙花数是指一个 n 位数 ( n >= 3 ),它的每个位上的数字的 n 次幂之和等于它本身。(例如
阅读全文
摘要:一个矩形的面积为S,已知该矩形的边长都是整数,求所有满足条件的矩形中,周长的最小值。例如:S = 24,那么有{1 24} {2 12} {3 8} {4 6}这4种矩形,其中{4 6}的周长最小,为20。 一个矩形的面积为S,已知该矩形的边长都是整数,求所有满足条件的矩形中,周长的最小值。例如:S
阅读全文
摘要:1,10,100,1000...组成序列1101001000...,求这个序列的第N位是0还是1。 1,10,100,1000...组成序列1101001000...,求这个序列的第N位是0还是1。 Input 第1行:一个数T,表示后面用作输入测试的数的数量。(1 <= T <= 10000) 第
阅读全文
摘要:给出一个数N,求1至N中,有多少个数不是2 3 5 7的倍数。 例如N = 10,只有1不是2 3 5 7的倍数。 给出一个数N,求1至N中,有多少个数不是2 3 5 7的倍数。 例如N = 10,只有1不是2 3 5 7的倍数。 给出一个数N,求1至N中,有多少个数不是2 3 5 7的倍数。 例如
阅读全文
摘要:给出一个整数N,输出N^N(N的N次方)的十进制表示的末位数字。 给出一个整数N,输出N^N(N的N次方)的十进制表示的末位数字。 给出一个整数N,输出N^N(N的N次方)的十进制表示的末位数字。 Input 一个数N(1 <= N <= 10^9) Output 输出N^N的末位数字 Input示
阅读全文
摘要:给出一个字符串S(可能有重复的字符),按照字典序从小到大,输出S包括的字符组成的所有排列。例如:S = "1312", 输出为: 1123 1132 1213 1231 1312 1321 2113 2131 2311 3112 3121 3211 给出一个字符串S(可能有重复的字符),按照字典序从
阅读全文
摘要:n的阶乘后面有多少个0? 6的阶乘 = 1*2*3*4*5*6 = 720,720后面有1个0。 n的阶乘后面有多少个0? 6的阶乘 = 1*2*3*4*5*6 = 720,720后面有1个0。 n的阶乘后面有多少个0? 6的阶乘 = 1*2*3*4*5*6 = 720,720后面有1个0。 6的阶
阅读全文
摘要:给出两个字符串A B,求A与B的最长公共子序列(子序列不要求是连续的)。 比如两个串为: abcicba abdkscab ab是两个串的子序列,abc也是,abca也是,其中abca是这两个字符串最长的子序列。 给出两个字符串A B,求A与B的最长公共子序列(子序列不要求是连续的)。 比如两个串为
阅读全文
摘要:We are all familiar with sorting algorithms: quick sort, merge sort, heap sort, insertion sort, selection sort, bubble sort, etc. But sometimes it is
阅读全文
摘要:A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence of the given numeric sequence ( a1, a2, ..., aN) be any sequence ( ai1,
阅读全文
摘要:A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = <x1, x2, ..., xm> another se
阅读全文
摘要:编辑距离,又称Levenshtein距离(也叫做Edit Distance),是指两个字串之间,由一个转成另一个所需的最少编辑操作次数。许可的编辑操作包括将一个字符替换成另一个字符,插入一个字符,删除一个字符。 例如将kitten一字转成sitting: sitten (k->s) sittin (
阅读全文
摘要:X*X mod P = A,其中P为质数。给出P和A,求<=P的所有X。 X*X mod P = A,其中P为质数。给出P和A,求<=P的所有X。 X*X mod P = A,其中P为质数。给出P和A,求<=P的所有X。 Input 两个数P A,中间用空格隔开。(1 <= A < P <= 100
阅读全文
摘要:输入N和P(P为质数),求N! Mod P = ? (Mod 就是求模 %) 例如:n = 10, P = 11,10! = 3628800 3628800 % 11 = 10 输入N和P(P为质数),求N! Mod P = ? (Mod 就是求模 %) 例如:n = 10, P = 11,10!
阅读全文
摘要:N个人坐成一个圆环(编号为1 - N),从第1个人开始报数,数到K的人出列,后面的人重新从1开始报数。问最后剩下的人的编号。 例如:N = 3,K = 2。2号先出列,然后是1号,最后剩下的是3号。 N个人坐成一个圆环(编号为1 - N),从第1个人开始报数,数到K的人出列,后面的人重新从1开始报数
阅读全文
摘要:给出3个正整数A B C,求A^B Mod C。 例如,3 5 8,3^5 Mod 8 = 3。 给出3个正整数A B C,求A^B Mod C。 例如,3 5 8,3^5 Mod 8 = 3。 例如,3 5 8,3^5 Mod 8 = 3。 Input 3个正整数A B C,中间用空格分隔。(1
阅读全文
摘要:给出长度为N的数组,找出这个数组的最长递增子序列。(递增子序列是指,子序列的元素是递增的) 例如:5 1 6 8 2 4 5 10,最长递增子序列是1 2 4 5 10。 给出长度为N的数组,找出这个数组的最长递增子序列。(递增子序列是指,子序列的元素是递增的) 例如:5 1 6 8 2 4 5 1
阅读全文