当前位置:网站首页>Codeforces Round #716 (Div. 2)
Codeforces Round #716 (Div. 2)
2022-06-27 22:03:00 【My story was traded for wine】
2021.4.19
A
The question : Here you are. n Sequence of Numbers , Ask you if there is a subsequence whose product is not a square number
Answer key : Judge n Whether the sequence of numbers is a complete square number
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
int n,x,t;
cin>>t;
while(t--){
cin>>n;
int flag=0;
for(int i=0;i<n;i++)
{
cin>>x;
int k=(int)sqrt(x);
if(k*k!=x)
flag=1;
}
if(flag)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return 0;
}
B
The question : Enter two numbers n and k, It is required to construct a n Sequence of Numbers , And selected n Number needs to be from 0~
To choose , All elements are required to be bitwise AND 0 And the sum of all elements is the largest , Find the number of schemes that can be constructed .
Answer key : Sequence from 0~
Choose from , So it can be seen that every number can be reduced to a length of k Binary number of , All elements are required to be bitwise AND 0,k Bit binary each bit must have one 0, this k individual 0 It's from n Number of contributions , Demand and maximum , So every one has and only one 0, All the others in the same position should be 1, So each of these 0 Can be placed in n On the corresponding bit of the number , every last 0 Yes n A choice , All in all k individual 0, The answer is
%1e9+7.
#include <cstdio>
#include <iostream>
#include <algorithm>
#define ll long long
#define mod 1000000007
using namespace std;
ll qpow(ll a,ll b)
{
ll res=1;
while(b)
{
if(b%2)
res=res*a%mod;
a=a*a%mod;
b/=2;
}
return res;
}
int main()
{
ll t,n,k;
cin>>t;
while(t--)
{
cin>>n>>k;
cout<<qpow(n,k)%mod<<endl;
}
return 0;
}
C
The question : Enter a number n, from [1,2,…,n−1] Select the sequence with the longest length , Make the product of the sequence remainder n by 1
Answer key :
Pei genus theorem : For non negative integers a,b, There is x,y bring ax+by=gcd(a,b), in other words ax+by The smallest positive integer that can be formed is gcd(a,b), Be careful (a,b Different at the same time 0)
ax+by=c There is a solution if and only if c%gcd(a,b)==0, If gcd(a,b)>1 that c Must be greater than 1, therefore gcd(k,n)>1,
, So the product of the sequence is required %n=1, Need from gcd(k,n)=1 Middle search .
Make :
, At this time sum
[1,n), The remainder is required to be 1, be ans=sum/sum=1, Let's put the in the product sum Removing the product of the sequence is 1, In this way, we only need to delete one number to get the product remainder of the sequence n by 1.
What then? sum It must be in s Li ?
Suppose there is no mold , And that's what we end up with ans%n=1, therefore ans It must be s The product of the numbers in , and sum yes s The product of all numbers in ,ans*x=sum, So this x It must be s Number in Li , That is, after the above mold taking sum, So you can go from s Removed from .
#include <cstdio>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
ll gcd(ll a,ll b)
{
return b==0?a:gcd(b,a%b);
}
int main()
{
ll n,ans=1,a[100005],l=0;
cin>>n;
for(int i=1;i<n;i++)
{
if(gcd(i,n)==1){
a[l++]=i;
ans=(ans*i)%n;
}
}
if(ans!=1){
cout<<l-1<<endl;
for(int i=0;i<l;i++)
if(a[i]!=ans)
cout<<a[i]<<' ';
}
else{
cout<<l<<endl;
for(int i=0;i<l;i++)
cout<<a[i]<<' ';
}
cout<<endl;
return 0;
}
边栏推荐
- VMware virtual machine PE startup
- [LeetCode]动态规划解拆分整数I[Silver Fox]
- Management system itclub (Part 2)
- [LeetCode]186. Flip word II in string
- QT base64 encryption and decryption
- Oracle migration MySQL unique index case insensitive don't be afraid
- Common problems encountered by burp Suite
- Quick excel export
- [sword offer ii] sword finger offer II 029 Sorted circular linked list
- 豆沙绿保护你的双眼
猜你喜欢

win11桌面出現“了解此圖片”如何删除
![\W and [a-za-z0-9_], \Are D and [0-9] equivalent?](/img/96/2649c9cf95b06887b57fd8af2d41c2.png)
\W and [a-za-z0-9_], \Are D and [0-9] equivalent?

win11桌面出现“了解此图片”如何删除

I think I should start writing my own blog.

This set of steps for performance testing using JMeter includes two salary increases and one promotion

Stm32cubeide1.9.0\stm32cubemx 6.5 f429igt6 plus lan8720a, configure eth+lwip

At 19:00 on Tuesday evening, the 8th live broadcast of battle code Pioneer - how to participate in openharmony's open source contribution in multiple directions

∫(0→1) ln(1+x) / (x² + 1) dx

真香,自从用了Charles,Fiddler已经被我彻底卸载了

管理系统-ITclub(下)
随机推荐
[Sword Offer II]剑指 Offer II 029. 排序的循环链表
IO stream code
Go from introduction to actual combat - only any task is required to complete (notes)
軟件測試自動化測試之——接口測試從入門到精通,每天學習一點點
excel读取文件内容方法
linux下安装oracle11g 静默安装教程
Simulink method for exporting FMU model files
TreeSet details
管理系统-ITclub(下)
Go 访问GBase 8a 数据库的一个方法
读写分离-Mysql的主从复制
[leetcode] dynamic programming solution partition array i[red fox]
管理系统-ITclub(上)
Bean paste green protects your eyes
开源技术交流丨一站式全自动化运维管家ChengYing入门介绍
Gbase 8A OLAP analysis function cume_ Example of dist
Xiao Wang's interview training task
语言弱点列表--CWE,一个值得学习的网站
Go from introduction to practice -- coordination mechanism (note)
Gbase 8A OLAP analysis function cume_ Example of dist