a、hzy 和zsl 的生存挑战
思路:看见“假设他们都足够机智”就够了,全输出1.00就ac
#include
#define INF 0x3f3f3f3f
#define ll long long
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define lcm(a,b) ((a)*(b)/(__gcd((a),(b))))
#define Max 3e5+10
#define mod 192600817
using namespace std;
int main() {
printf("%.2f\n",4/4.0);
printf("%.2f\n",4/4.0);
printf("%.2f\n",4/4.0);
printf("%.2f\n",4/4.0);
return 0;
}
b、人类史上最大最好的希望事件
思路:暴力算。。。
#include
#define INF 0x3f3f3f3f
#define ll long long
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define lcm(a,b) ((a)*(b)/(__gcd((a),(b))))
#define Max 3e5+10
#define mod 192600817
using namespace std;
ll t, a, b, c, d, fb[50010], m[50010];
void init() {
fb[1] = 1;
m[1] = 1;
for(int i = 2; i < 50010; i++) {
fb[i] = (fb[i - 1] + fb[i - 2]) % mod;
m[i] = (fb[i] * fb[i]) % mod + m[i - 1];
}
}
int main() {
while(cin >> t) {
init();
while(t--) {
cin >> a >> b >> c >> d;
a = a * 4 + b + 1;
c = c * 4 + d + 1;
if(a > c)
swap(a, c);
ll ans = 0;
ans = (m[c] - m[a - 1]) % mod;
cout << ans % mod << endl;
}
}
return 0;
}
c、超级无敌简单题
思路:数据没那么大,预处理一下,遇见不行的及时return。
#include
#define INF 0x3f3f3f3f
#define ll long long
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define lcm(a,b) ((a)*(b)/(__gcd((a),(b))))
#define Max 3e5+10
#define mod 192600817
using namespace std;
int ge[150010], g;
int gts(int y) {
int ans = 0, x = y;
while(x != 0) {
int k = x % 10;
x /= 10;
ans += k * k;
}
return ans;
}
int isge(int k) {
int s=k;
while(1){
s=gts(s);
if(s==1)return 1;
if(s==2||s==3||s==4||s==5||s==6||s==8||s==9||s==14||s==15||s==16||s==17||s==18||s==25||s==30)return 0;
}
}
int main() {
for(int i = 1; i <= 1000000; i++) {
if(isge(i)) {
ge[++g] = i;
}
}
int t;
cin >> t;
while(t--) {
int k;
cin >> k;
cout << ge[k] << endl;
}
return 0;
}
g、简单数学题
思路:在纸上分开写后发现可以套用这个公式。
然后利用等比数列求和来简化计算
#include
#define INF 0x3f3f3f3f
#define ll long long
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define lcm(a,b) ((a)*(b)/(__gcd((a),(b))))
#define Max 3e5+10
#define mod 1000000007
using namespace std;
ll n;
ll poww(ll a, ll b) {
ll ans = 1, push = a;
while(b > 0) {
if(b & 1) {
ans *= push;
ans %= mod;
}
push *= push;
push %= mod;
b >>= 1;
}
return ans % mod;
}
int main() {
while(~scanf("%lld", &n)) {
cout << (n - 1) % mod * poww(2, n) % mod + 1 << endl;
}
return 0;
}
j、Count
思路:矩阵快速幂。
将转换成
f(n+1)=f(n)+2*f(n-1)+ 根据这个构造矩阵。
#include
#define INF 0x3f3f3f3f
#define ll long long
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define lcm(a,b) ((a)*(b)/(__gcd((a),(b))))
#define Max 3e5+10
#define mod 123456789
using namespace std;
ll t, n, k;
struct mtx {
ll x[6 + 1][6 + 1];
mtx() {
memset(x, 0, sizeof x);
}
} ans;
mtx operator *(const mtx &a, const mtx &b) {
mtx c;
for(int i = 0; i < 6; i++)
for(int j = 0; j < 6; j++)
for(int k = 0; k < 6; k++)
c.x[i][j] = (c.x[i][j] + a.x[i][k] * b.x[k][j] % mod) % mod;
return c;
}
mtx operator ^(mtx a, ll k) {
mtx ret;
for(int i = 0; i < 6; ++i)
ret.x[i][i] = 1;
while(k) {
if(k & 1)
ret = ret * a;
a = a * a;
k >>= 1;
}
return ret;
}
int main() {
cin >> t;
while(t--) {
mtx ak;
cin >> n;
if(n == 1) {
cout << 1 << endl;
continue;
} else if(n == 2) {
cout << 2 << endl;
continue;
}
ak.x[0][0] = 1;
ak.x[0][1] = 2;
ak.x[0][2] = 1;
ak.x[0][3] = 3;
ak.x[0][4] = 3;
ak.x[0][5] = 1;
ak.x[1][0] = 1;
ak.x[2][2] = 1;
ak.x[2][3] = 3;
ak.x[2][4] = 3;
ak.x[2][5] = 1;
ak.x[3][3] = 1;
ak.x[3][4] = 2;
ak.x[3][5] = 1;
ak.x[4][4] = 1;
ak.x[4][5] = 1;
ak.x[5][5] = 1;
mtx ans = ak ^ (n - 2);
ll as = (2 * ans.x[0][0] % mod + ans.x[0][1] + 8 * ans.x[0][2] % mod + 4 * ans.x[0][3] % mod + 2 * ans.x[0][4] % mod + ans.x[0][5]) % mod;
cout << as << endl;
}
return 0;
}