题目:Abstract Painting Kattis - abstractpainting
分析:
一图胜千言(妙不可言,美不胜收,这题妙,我吃了)
代码:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef __int128 lll;
#define print(i) cout << "debug: " << i << endl
#define close() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define mem(a, b) memset(a, b, sizeof(a))
const ll mod = 1e9 + 7;
const int maxn = 2e6;
const int inf = 0x3f3f3f3f;
ll qpow(ll a, ll n)
{
ll res = 1;
while (n)
{
if(n & 1) res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
int main()
{
int t; cin >> t;
while (t--)
{
int r, c; cin >> r >> c;
cout << qpow(3, r + c) * qpow(2, r * c) % mod << endl;
}
}
题目:D - Dating time
分析:
一开始枚举的是秒数,然后再求夹角,这样就会导致判断两个指针是否在这一秒内重合变得非常麻烦。本题正确打开方式应该将整个表分成43200份,夹角差值的单位设为1份,然后枚举份数即可。(wtcl)
代码:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef __int128 lll;
#define print(i) cout << "debug: " << i << endl
#define close() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define mem(a, b) memset(a, b, sizeof(a))
const ll mod = 1e9 + 7;
const int maxn = 2e6;
const int inf = 0x3f3f3f3f;
const int tim = 43200;
int main()
{
int t; cin >> t;
while (t--)
{
int h1, m1, h2, m2, tar;
scanf("%d:%d %d:%d %d", &h1, &m1, &h2, &m2, &tar);
int start = (h1 * 3600 + m1 * 60) * 11, end = (h2 * 3600 + m2 * 60) * 11;
int res = 0;
for(int i = start; i <= end; i++)
{
if(tar == 0 && i % tim == 0) res++;
if(tar == 90 && (i % tim == 10800 || i % tim == 32400)) res++;
if(tar == 180 && i % tim == 21600) res++;
}
cout << res << endl;
}
}