1 动态密码
思路:可以直接填空也可以写程序
void solve()
{int a = 20241111;stack<int> stk;while(a){stk.push(a % 2);a /= 2;}while(stk.size()){cout << stk.top();stk.pop();}}
2 购物车里的宝贝
思路:总体异或和为0即可说明可分成一样的两组
int n;
int ans;void solve()
{cin >> n;int x;for (int i = 1;i <= n;i ++) cin >> x,ans ^= x;cout << (ans == 0 ? "YES" : "NO") << endl;
}
4 蓝桥商场
思路:ans累加最大的数需要的步骤数的同时依次减去小的步骤
const int N = 1e5 + 9; int n;
LL ans;
int a[N];void solve()
{// 30201 2*n - 1 // 2 2 2 (6)// 3 3 3 cin >> n;for (int i = 1;i <= n;i ++) cin >> a[i]; sort(a + 1,a + 1 + n);for (int i = 1,j = n;i <= j;j--){// cout << j << "-" << endl;LL tmp = 2 * a[j] - 1;ans += tmp;while(2 * a[i] - 1 <= tmp){tmp -= 2 * a[i] - 1;i ++;}}cout << ans << endl; }
6 薅羊毛
思路:相邻两个数的gcd为1,相邻两个数的幂的gcd也为1
const int p = 1e9 + 7;LL L,R;LL qmi(LL a,LL b)
{LL ans = 1;while(b){if (b & 1) ans = ans * a % p;a = a * a % p;b >>= 1;}return ans;
} void solve()
{cin >> L >> R;LL ans = 0;for (int i = L;i < R;i ++){LL a = qmi(i,i);LL b = qmi(i + 1,i + 1);LL val = (a * b % p) ;ans = (ans + val) % p;}cout << ans << endl;
}