当前位置:网站首页>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;
}
边栏推荐
- C language programming detailed version (learning note 1) I can't understand it after reading, and I can't help it.
- 熊市慢慢,Bit.Store提供稳定Staking产品助你穿越牛熊
- GBase 8a V8版本节点替换期间通过并发数控制资源使用减少对系统影响的方法
- CDH集群之YARN性能调优
- regular expression
- Software test automation test -- interface test from entry to proficiency, learn a little every day
- Yarn中RMApp、RMAppAttempt、RMContainer和RMNode状态机及其状态转移
- 清华大学教授:软件测试已经走入一个误区——“非代码不可”
- Professor of Tsinghua University: software testing has gone into a misunderstanding - "code is necessary"
- VMware virtual machine PE startup
猜你喜欢

STM32F107+LAN8720A使用STM32cubeMX配置网络连接+tcp主从机+UDP app

Stm32f107+lan8720a use stm32subemx to configure network connection +tcp master-slave +udp app

Go from introduction to actual combat -- channel closing and broadcasting (notes)

深度学习又有新坑了!悉尼大学提出全新跨模态任务,用文本指导图像进行抠图

洛谷P5706 再分肥宅水

熊市慢慢,Bit.Store提供稳定Staking产品助你穿越牛熊

AQS SOS AQS with me

Figure countdownlatch and cyclicbarrier based on AQS queue

使用Fiddler模拟弱网测试(2G/3G)

Read write separation master-slave replication of MySQL
随机推荐
管理系统-ITclub(下)
Go from introduction to practice - polymorphism (note)
Quick excel export
linux下安装oracle11g 静默安装教程
如何做好功能测试?你确定不想知道吗?
[LeetCode]186. Flip word II in string
[sword offer ii] sword finger offer II 029 Sorted circular linked list
\W and [a-za-z0-9_], \Are D and [0-9] equivalent?
[LeetCode]186. 翻转字符串里的单词 II
C语言程序设计详细版 (学习笔记1) 看完不懂,我也没办法。
Interview question 3 of software test commonly used by large factories (with answers)
GBase 8a OLAP分析函数 cume_dist的使用样例
[LeetCode]动态规划解拆分整数I[Silver Fox]
使用Fiddler模拟弱网测试(2G/3G)
Yarn中RMApp、RMAppAttempt、RMContainer和RMNode状态机及其状态转移
Go from introduction to practice -- coordination mechanism (note)
STM32CubeIDE1.9.0\STM32CubeMX 6.5 F429IGT6加LAN8720A,配置ETH+LWIP
Installing Oracle11g under Linux
畅游动态规划之区间DP
Open source technology exchange - Introduction to Chengying, a one-stop fully automated operation and maintenance manager