成绩回顾:
第一题:
题干:
AC代码:
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
void solve(){
int n , x;
cin >> n >> x;
if(n == 1 or n == 2){
cout << 1 << endl;
}else{
if((n -2) % x == 0){
cout << ((n -2) /x )+1 << endl;
}else{
cout << ((n -2) /x )+2 << endl;
}
}
}
int main(void){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int T;
cin >> T;
while(T--){
solve();
}
return 0;
}
第二题:
题干:
AC代码:
#include <bits/stdc++.h>
using namespace std;
struct node {
int a1;
int a2;
int a3;
int a4;
};
void solve(){
int n , m;
cin >> n >> m;
vector<node> a(n);
bool flag = false;
for(int i = 0 ;i < n ; i++){
cin >> a[i].a1 >> a[i].a2 >> a[i].a3 >> a[i].a4;
if(a[i].a2 == a[i].a3){
flag = true;
}
}
if(m % 2 != 0){
flag = false;
}
if(flag){
cout << "Yes\n";
}else{
cout << "No\n";
}
}
int main(void){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int T;
cin >> T;
while(T--){
solve();
}
return 0;
}
第三题:
题干:
AC代码:
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
const int N = 1e5+5;
#define int long long
void solve(){
double n;
cin >> n;
if(n == 1){
cout << 0 << endl;
}
else{
int tmp = (sqrt((double)n));
int res;
if((( 1 + 1*(tmp - 1) ) + ( tmp - 1 ) *( 1 + 1*(tmp - 1) ) )>= n){
res = tmp*2 - 2;
}else if((( 1 + 1*(tmp - 1) ) + ( tmp) *( 1 + 1*(tmp - 1) ) )>= n){
res = tmp*2 - 1;
}else{
res = tmp*2;
}
cout << res << endl;
}
}
signed main(void){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int T;
cin >> T;
while(T--){
solve();
}
return 0;
}
第四题:
题干:
AC代码:
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e5 + 5;
set<int> a;
void solve(){
int t;
cin >> t;
int res = 0;
int sum = 0;
a.insert(0);
for(int i = 0; i < t ; i++){
int tmp ;
cin >> tmp;
sum += tmp;
if(a.find(sum) != a.end()){
res++;
a.clear();
a.insert(0);
sum = tmp;
}
a.insert(sum);
}
cout << res;
}
signed main(void){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int T = 1;
// cin >> T;
while(T--){
solve();
}
return 0;
}
第五题:
题干:
AC代码:
#include <bits/stdc++.h>
using namespace std;
struct node{
int r;
int s;
int p;
};
void solve(){
int n;
cin >> n ;
node a,b;
cin >> a.r >> a.s >> a.p;
cin >> b.r >> b.s >> b.p;
int nr = min(a.r,b.s);
int ns = min(a.s,b.p);
int np = min(a.p,b.r);
int res2 =nr + ns + np;
int sum = 0;
sum += min(b.p + b.r , a.r);
sum += min(b.s + b.p , a.p);
sum += min(b.r + b.s , a.s);
int res1 = n - sum;
cout << res1 << ' ' << res2;
}
int main(void){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int T = 1;
// cin >> T;
while(T--){
solve();
}
return 0;
}
第六题:
涉及DP博主还没学,留坑。