Drawing Book
水题,推公式
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;
int main(){
int n;
cin >> n;
int p;
cin >> p;
cout<<min(p/2,(n-p)/2)<<endl;
return 0;
}
Tailor Shop
有n个群,每个群有规定的最小的钱,每个按钮有规定的价格,问最少的使用的按钮的数量
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1e5+100;
int a[maxn];
int n,p;
int main() {
scanf("%d %d",&n,&p);
for(int i = 0 ;i<n;i++) scanf("%d",&a[i]);
sort(a,a+n);
LL num = 1;
LL ans = 0;
for(int i = 0;i<n;i++) {
while(num*p<a[i]) num++;
ans+=num;
num++;
}
printf("%lld\n",ans);
return 0;
}
Hackonacci Matrix Rotations
定义
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int n,q;
int ln[2001][2001];
int a[2001][2001];
int ans[5],Angle;
int b[] = {0,1,0,1,0,0,1,1};
int Get(int i,int j) {
int ant = (i*j)%7;
ant = (ant*ant)%7;
return ant == 0?7:ant;
}
void Ratote() {
for(int i = 1;i<=(n/2);i++) {
for(int j = 1;j<=n;j++)
swap(a[i][j],a[n+1-i][j]);
}
for(int i = 1;i<=n;i++) {
for(int j = 1;j<=i;j++) swap(a[i][j],a[j][i]);
}
}
int Diff() {
int ant = 0;
for(int i = 1;i<=n;i++)
for(int j = 1;j<=n;j++)
ant+=(ln[i][j] == a[i][j]?0:1);
return ant;
}
int main() {
scanf("%d %d",&n,&q);
for(int i = 1;i<=n;i++) {
for(int j = 1;j<=n;j++) {
a[i][j] = b[Get(i,j)];
ln[i][j] = a[i][j];
}
}
ans[0] = 0;
for(int i =1;i<=3;i++) {
Ratote();
ans[i] = Diff();
}
while(q--) {
scanf("%d",&Angle);
(Angle/=90)%=4;
printf("%d\n",ans[Angle]);
}
return 0;
}
Zero-Move Nim
改变的Nim博弈,对于非空的石堆,有一次不用拿的机会。手写几个SG就会发现做法的
#include <bits/stdc++.h>
using namespace std;
int T,n;
int main() {
scanf("%d",&T);
while(T--) {
scanf("%d",&n);
int ans = 0,data;
for(int i = 1;i<=n;i++) {
scanf("%d",&data);
ans ^= data+(data%2==0?-1:1);
}
if(ans) printf("W\n");
else printf("L\n");
}
return 0;
}