A. Two Regular Polygons
- 题意:给你一个 正n边形,问你能否以这个 n 的其中一些顶点组成一个 m边形,
- 思路 :如果 n % m == 0 ,就可
- 收获:边均分
B. Bogosort(思维分析)
- 题意:给你一个序列 a1 ,a2, …an, 能否在经过你任意的排序否满足,在序列中的任意两个元素 𝑗−𝑎𝑗≠𝑖−𝑎i ,其中(i < j).
- 思路:我们可以把给我们的式子做变形为 :ai + (j - i) != aj ,这里主要 j > i ,所以 i - j 大于 0,其实我们只需要 把序列 a 从大到小排序,就 恒符合上式,,然后就出答案了,,,,,,,,,好水的题。。。。。
- 收获:给我们一个表达式我们要进行 左右移动转化,看能否 得出更有用、清晰的条件
C .Adding Powers codeforces(位运算&&思维)
outputstandard output Suppose you are performing the following
algorithm. There is an array v1,v2,…,vn filled with zeroes at start.
The following operation is applied to the array several times — at
i-th step (0-indexed) you can:either choose position pos (1≤pos≤n) and increase vpos by ki; or not
choose any position and skip this step. You can choose how the
algorithm would behave on each step and when to stop it. The question
is: can you make array v equal to the given array a (vj=aj for each j)
after some step?Input The first line contains one integer T (1≤T≤1000) — the number of
test cases. Next 2T lines contain test cases — two lines per test
case.The first line of each test case contains two integers n and k
(1≤n≤30, 2≤k≤100) — the size of arrays v and a and value k used in the
algorithm.The second line contains n integers a1,a2,…,an (0≤ai≤1016) — the array
you’d like to achieve.Output For each test case print YES (case insensitive) if you can
achieve the array a after some step or NO (case insensitive)
otherwise.Example inputCopy 5 4 100 0 0 0 0 1 2 1 3 4 1 4 1 3 2 0 1 3 3 9 0
59049 810 outputCopy YES YES NO NO YES Note In the first test case,
you can stop the algorithm before the 0-th step, or don’t choose any
position several times and stop the algorithm.In the second test case, you can add k0 to v1 and stop the algorithm.
In the third test case, you can’t make two 1 in the array v.
In the fifth test case, you can skip 90 and 91, then add 92 and 93 to
v3, skip 94 and finally, add 95 to v2.
- 思路:这一题其实 就是根据位运算的思想,我们把所给的数都转化成 k进制数,看看总共的k进制位上,是否有的数大于 1, 若果有就不可能了
- 代码
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
int main()
{
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//freopen("A.txt","r",stdin);
int t;
cin >> t;
while(t --)
{
int n,k;
cin >> n >> k;
int ar[65] = {0};
int flag = 1;
for(int i = 1; i <= n; i ++)
{
long long tem, pos = 0;
cin >> tem;
while(tem && flag) // 类似于进制拆分的思想
{
ar[pos] += tem % k;
tem /= k;
if(ar[pos] >= 2) flag = 0;
pos ++;
}
}
if(flag)
cout << "YES\n";
else
cout << "NO\n";
}
return 0;
}
- 收获:这一题巧妙的把一个数的不同k次方数,相加得到一个新新的次方数,而我们通过转化成k进制的思想,去判读某个数是否重复出现,,这里更重要的是 某个数的不同k次方之和,可以转化为 k进制的出现次数来处理。。。