A(签到): 考察不同数据类型的数据范围,超出范围会溢出(导致答案错误的关键)
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'

void solve(){
    long long  a,b;cin>>a>>b;
    long long ans=a-b-b*10;
    cout<<ans;

}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int t = 1;
    // cin>>t;
    while (t--) solve();
}

B 典型的倍增求和:1->2->4->8->16
ans=1+2+4+8+16;
可以一个个的求出来再加起来,也可以用 ans=ans*2+1,直接统计最终答案
原因就是: (4+2)+1-->  (8+4+2)+1->(16+8+4+2)+1---> 其实就是相当于倒着算的答案,乘2,就是因为又操作了一次得把前面的翻倍,再加上自己的1

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
void solve(){
    int n;cin>>n;
    int ans=0;
    while(n){
        n/=2;
        ans=ans*2+1;
    }
    cout<<ans;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int t = 1;
    // cin>>t;
    while (t--) solve();
}
C:只需要按照题目的意思,在 i==x 的时候跳过就行了,记录一下最大值,是最大值 ans++就行了,按照题目意思模拟一下就行

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'

void solve(){
    int n,x;cin>>n>>x;
    int ans=0,ma=0;
    for(int i=1;i<=n;i++){
        int e;cin>>e;
        if(i==x) continue;
        if(ma<e) ma=e,ans=0;  //之前记录的不是最大值,就换一下,记录的答案重置
        if(ma==e) ans++;
    }
    cout<<ans<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int t = 1;
    // cin>>t;
    while (t--) solve();
}

D:涉及因数分解(不会的上网学一下)
在这里每一个灯的状态: 只与他的因子有关,因子的个数决定了这个灯的状态改变的次数(前提是这个因子得在1~n)

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'

void solve(){
    int n,x;cin>>n>>x;
    int ct=0;
    for(int i=1;i*i<=x;i++){
        if(x%i!=0) continue;
        if(i>n) break;
        ct++;
        if(x/i!=i&&x/i<=n) ct++;
    }
    if(ct&1) cout<<"ON";
    else cout<<"OFF";

}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int t = 1;
    // cin>>t;
    while (t--) solve();
}

E:这题就是一个简单模拟,唯一值得注意的就是 a 的范围很大,long long 也是存不下的
所以只能利用字符串来写 

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
void solve(){
    int n;cin>>n;
    vector<string>s(n+1);
    for(int i=1;i<=n;i++) cin>>s[i];
    int all=0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<s[i].size();j++){
            all+=s[i][j]-'0';//这里是利用了字符的ascll码值,将字符转为数字
        }
    }
    if(all%3==0) cout<<"YES";//小学数学
    else cout<<"NO";
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int t = 1;
    // cin>>t;
    while (t--) solve();
}

F: 题目有点繁琐,得学会自己画图分情况,便于快速理解分析题目,如图(太大可以缩小看)  注意:  a<=b<=c
看着这个图: 题目意思要时间最短,贪心的想: 1.是不是可以直接充电     2.如果一开始电量就小于等于t就可以直接超充(一定是最优的,c最大) 3.可以先玩掉一点电量,再超充(玩的时候,选y和a中大的那个)
因为数据的不确定  方案1与方案3那个最优,是不确定的,都算出来取最小就行

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'

void solve(){
    double x,y,t,a,b,c;
    cin>>x>>y>>t>>a>>b>>c;
    double ans1=0,ans2=0;
    if(x<=t){// 超充
        ans1=(100-x)/c;
        printf("%.10f",ans1);
        return;
    }
    ans1=(100-x)/b;//直接充
    if(y<a) swap(a,y);//先玩再充
    ans2=(x-t)/y+(100-t)/c;//x-->t-->100
    ans1=min(ans1,ans2);
    printf("%.10f",ans1);

}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int t = 1;
    // cin>>t;
    while (t--) solve();
}


G:上学期出的最大 “子段和”,没写出来的自己反思
只需要稍微处理一下 ---->原价-x  == 省的钱 --->最大子段和的模板  (贪心的思想)
实在不会: 上网搜:  最大子段和
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'

void solve(){
    int n,x;cin>>n>>x;
    vector<int>a(n+1);
    for(int i=1;i<=n;i++){
        cin>>a[i];
        a[i]-=x;
    }
    int now=0,ma=0;
    for(int i=1;i<=n;i++){
        if(now<0) now=0;
        now+=a[i];
        ma=max(ma,now);
    }
    cout<<ma;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int t = 1;
    // cin>>t;
    while (t--) solve();
}