D. Optimal Number Permutation time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have array a that contains all integers from 1 to n twice. You can arbitrary permute any numbers in a. Let…
题目链接: B. Kyoya and Permutation time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Let's define the permutation of length n as an array p = [p1, p2, ..., pn] consisting of n distinct integers…
D. Optimal Number Permutation 题目连接: http://www.codeforces.com/contest/622/problem/D Description You have array a that contains all integers from 1 to n twice. You can arbitrary permute any numbers in a. Let number i be in positions xi, yi (xi < yi) i…
A. Hanoi tower Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Description you the conditions of this task. There are 3 pivots: A, B, C. Initially, n disks of different diameter are placed on the pivot A: the smallest dis…
BOPCTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86686#problem/D Description You invented a new chess figure and called it BOPC. Suppose it stands at the square grid at the point with coordinates …
Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4288    Accepted Submission(s): 1066 Problem Description Here are two numbers A and B (0 < A <= B). If B cannot be divisible by A, and A…
题目链接:http://lightoj.com/volume_showproblem.php?problem=1245 题意就是求 n/i (1<=i<=n) 的取整的和这就是到找规律的题, i     1  2   3   4   5   6   7    8 a    8  4   2   2   1   1   1    1 你可以多写几组你会发现 有8-4个1:4-2个2:...其他例子也是这样: 当n = 10时 n/1 = 10, n/2 = 5说明(5, 10]这个前开后闭的区间…
题目链接 题意:给你个x,k次操作,对于第i次操作是:要找个nx,使得nx是>=x的最小值,且能整除i,求k次操作后的数 分析: 经过打表找规律,会发现最后的x/i,这个倍数会趋于一个固定的值,求出这个固定的值和K相乘就可以了, 为什么会趋于固定的值呢,因为最后虽然i在不断增长,但是x也是在增长的,每次的倍数会回退一个发现 有余数,然后再加上一个,所以趋于稳定. 官方题解: #include <iostream> #include <cstdio> #include <…
一看就是找规律的题.只要熟悉异或的性质,可以秒杀. 为了防止忘记异或的规则,可以把异或理解为半加运算:其运算法则相当于不带进位的二进制加法. 一些性质如下: 交换律: 结合律: 恒等律: 归零律: 典型应用:交换a和b的值:a=a^b^(b=a); #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<…
是一个简单构造题. 请观察公式: 绝对值里面的就是 |di-(n-i)|,即di与(n-i)的差值的绝对值. 事实上,对于任何n,我们都可以构造出来每一个i的di与(n-i)的差值为0. 换句话说,就是这个最小值一定可以构造出来是0. 假设输入是6:那么可以这样构造:1 3 5 5 3 1 2 4 6 4 2 6 假设输入是7:那么可以这样构造:1 3 5 7 5 3 1 2 4 6 6 4 2 7 从上面就能看出怎么构造了,n最后放空缺的两个位置,剩下的从小到大一个一个放,奇数放左边构造,偶数…
题目链接 假设始终可以找到一种状态使得值为0, 那么两个1之间需要隔n-2个数, 两个2之间需要隔n-3个数, 两个3之间隔n-4个数. 我们发现两个三可以放到两个1之间, 同理两个5放到两个3之间....这样就构造好了. #include <iostream> #include <vector> #include <cstdio> #include <cstring> #include <algorithm> #include <cmat…
Another Rock-Paper-Scissors Problem 题目连接: http://codeforces.com/gym/100015/attachments Description Sonny uses a very peculiar pattern when it comes to playing rock-paper-scissors. He likes to vary his moves so that his opponent can't beat him with hi…
/** 题目:G - Harmonic Number (II) 链接:https://vjudge.net/contest/154246#problem/G 题意:给定一个数n,求n除以1~n这n个数的和.n达到2^31 - 1; 思路: 首先我们观察一下数据范围,2^31次方有点大,暴力会超时,所以我们看看有没有啥规律,假设 tmp 是 n/i 的值,当n == 10的时候(取具体值) 当 tmp = 1 时,个数 是10/1 - 10/2 == 5个 当 tmp = 2 时,个数 是10/2…
题目描述: Malek Dance Club time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output As a tradition, every year before IOI all the members of Natalia Fan Club are invited to Malek Dance Club to have a fu…
Problem B Number Sequence Input: standard input Output: standard output Time Limit: 1 second A single positive integer i is given. Write a program to find the digit located in the position i in the sequence of number groups S1S2…Sk. Each group Sk con…
Can the greatest common divisor and bitwise operations have anything in common? It is time to answer this question. Suppose you are given a positive integer aa. You want to choose some integer bb from 11to a−1a−1 inclusive in such a way that the grea…
Tree and Permutation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 0    Accepted Submission(s): 0 Problem Description There are N vertices connected by N−1 edges, each edge has its own length.…
D - Toll RoadTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87493#problem/D Description Exactly N years ago, a new highway between two major cities was built. The highway runs from west to east. It…
A prime number (or a prime) is a natural number greater than 11 that cannot be formed by multiplying two smaller natural numbers. Now lets define a number NN as the supreme number if and only if each number made up of an non-empty subsequence of all…
大致题意: 有一个W*H的长方形,有n个人,分别站在X轴或Y轴,并沿直线向对面走,第i个人在ti的时刻出发,如果第i个人与第j个人相撞了 那么则交换两个人的运动方向,直到走到长方形边界停止,问最后每个人的坐标. 题解: 两个人要相撞,当且仅当Xi-Ti=Xj-Tj,所以可以将Xi-Ti分组,对于同一组里的人会互相碰撞,不同组的不会,这样就只要考虑同一组里 的人,画个图可以发现,规律 然后根据规律化坐标即可 #include<cstdio> #include<cstring> #in…
[传送门]https://nanti.jisuanke.com/t/31452 [题目大意]:给定一个数字(最大可达10100),现在要求不超过它的最大超级质数.超级质数定义:对于一个数,把它看成数字序列 ,如果它的所有子序列形成的数都是质数,那么它就是超级质数. 比如说3137,它的子序列有3,1,7,31,33,37,313,317,137.....由于有一个子序列是33它不是质数,所有3137不是超级质数. [题解]注意,子序列和子串是不同的,子序列包含子串.子序列只要求相对顺序不变,而子…
一边长为a的直角三角形,a^2=c^2-b^2.可以发现1.4.9.16.25依次差3.5.7.9...,所以任何一条长度为奇数的边a,a^2还是奇数,那么c=a^2/2,b=c+1.我们还可以发现,1.4.9.16.25.36各项差为8.12.16.20,偶数的平方是4的倍数,那么c=a^2/4-1,b=a^2/4+1. #include <iostream> using namespace std; int main() { long long n; cin>>n; n*=n;…
题意:定义F(a,0) = 0,F(a,b) = 1 + F(a,b - GCD(a,b).给定 x 和 y (<=1e12)求F(x,y). 题解:a=A*GCD(a,b) b=B*GCD(a,b),那么b-GCD(a,b) = (B-1)*GCD(a,b),如果此时A和B-1依然互质,那么GCD不变下一次还是要执行b-GCD(a,b).那么GCD什么时候才会变化呢?就是说找到一个最小的S,使得(B-S)%T=0其中T是a的任意一个因子.变形得到:B%T=S于是我们知道S=min(B%T).也…
Codeforces 题目传送门 & 洛谷题目传送门 蠢蠢的我竟然第一眼想套通项公式?然鹅显然 \(5\) 在 \(\bmod 10^{13}\) 意义下并没有二次剩余--我真是活回去了... 考虑打表找规律(u1s1 这是一个非常有用的技巧,因为这个 \(10^{13}\) 给的就很灵性,用到类似的技巧的题目还有这个,通过对这些模数的循环节打表找出它们的共同性质,所以以后看到什么特殊的数据或者数据范围特别大但读入量 \(\mathcal O(1)\) 的题(比如 CF838D)可以考虑小数据打…
题意:给出一个n,生成n的所有全排列,将他们按顺序前后拼接在一起组成一个新的序列,问有多少个长度为n的连续的子序列和为(n+1)*n/2 题解:由于只有一个输入,第一感觉就是打表找规律,虽然表打出来了,但是依然没有找到规律...最后看了别人的题解才发现 ans [ 3 ] = 1*2*3 + ( ans [ 2 ] - 1 ) * 3 ans[ 4 ] = 1*2*3*4 + ( ans[ 3 ] - 1 ) * 4 感觉每次离成功就差一点点!!! #include<bits/stdc++.h>…
题目链接: http://codeforces.com/problemset/problem/353/D?mobile=true H. Queue time limit per test 1 secondmemory limit per test 256 megabytes 问题描述 There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The b…
Description You are given an integer N. Consider all possible segments (线段,划分)on the coordinate axis with endpoints at integer points with coordinates between 0 and N, inclusive; there will be  of them. You want to draw these segments in several laye…
Educational Codeforces Round 78 (Rated for Div. 2) 1278B - 6 B. A and B  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 can perform a sequence of…
题目描述: Little Elephant and Interval time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The Little Elephant very much loves sums on intervals. This time he has a pair of integers l and r (l ≤ r…
2014多校 第八题 1008 2014 Multi-University Training Contest 8 4952 Number Transformation Number Transformation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 85 Accepted Submission(s): 31 Problem Descr…