「Cfz Round 3」Battle
因为刚刚写的思路题意全删了,又是入门,直接上代码吧
代码:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void test()
{
ll n,m,p;
cin>>n>>m>>p;
m-=m%p;
if(m==0)
{
cout<<"Alice\n";
}else{
n-=n%p;
if(n==0)
{
cout<<"Bob\n";
}else{
cout<<"Lasting Battle\n";
}
}
}
signed main()
{
ll t;
cin>>t;
while(t--)test();
}
「Cfz Round 3」Change
题意:你可以对初始值为0的x数值进行,两个操作,第一个操作,将x乘以a,第二个操作,将x加上b
思路:首先我们对题进行操作,假如c等于0,那么肯定可以实现,因为b与p的最小公倍数,就肯定能模b成0,假如c!=0,那么只有当b==0的时候才不可能实现,否则可以,因为无穷多个p中肯定能将模p成为C
代码:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void test()
{
ll p,a,b,c;
cin>>p>>a>>b>>c;
if(c==0)
{
cout<<"YES"<<endl;
}else{
if(b==0)
{
cout<<"NO"<<endl;
}else{
cout<<"YES"<<endl;
}
}
}
signed main()
{
ll t;
cin>>t;
while(t--)test();
}
「Cfz Round 3」Xor with Gcd
题意:给一个n,求从1到n的所有的所有最大公约数的异或和
思路:打表找规律
代码:
#include <iostream>
using namespace std;
typedef unsigned long long ll;
ll calculate_xor_gcd(ll n) {
if (n % 2 == 0) {
return n ^ (n / 2);
} else {
return n;
}
}
int main() {
ll t;
cin >> t;
while (t--) {
ll n;
cin >> n;
ll result = calculate_xor_gcd(n);
cout << result << endl;
}
return 0;
}
j
这场比赛题我都会补
链接:【LGR-170-Div.3】洛谷基础赛 #6 & Cfz Round 3 & Caféforces #2 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)
浙公网安备 33010602011771号