// 二进制位数
// 11
#include<bits/stdc++.h>
#define CLOSE ios::sync_with_stdio(false);cin.tie(0) , cout.tie(0);
using namespace std;
using ll=long long;
typedef pair<int,int> PII;
const int N=1e6+10;
int main()
{
CLOSE
int x = 2022;
int c = 0;
while (x)
{
c++;
x /= 2;
}
cout << c;
return 0;
}
//晨跑 日期模拟
// 138
#include<bits/stdc++.h>
#define CLOSE ios::sync_with_stdio(false);cin.tie(0) , cout.tie(0);
using namespace std;
using ll=long long;
typedef pair<int,int> PII;
const int N = 1e6 + 10;
int ans;
int mon[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
int main()
{
CLOSE
int wek = 5;
for (int i = 1;i <= 12;i++)
{
for (int j = 1;j <= mon[i];j++)
{
++wek;
if (wek == 6 || wek == 7||j==1||j==11||j==21||j==31)
{
ans++;
if (wek == 7)wek = 0;
}
}
}
cout << ans;
return 0;
}
//调和级数
//91380
#include<bits/stdc++.h>
#define CLOSE ios::sync_with_stdio(false);cin.tie(0) , cout.tie(0);
using namespace std;
using ll=long long;
typedef pair<int,int> PII;
const int N=1e6+10;
int main()
{
CLOSE
double ans = 0;
int x = 0;
while (ans <= 12)
{
++x;
ans += 1.0 / x;
}
cout << x;
return 0;
}
//山谷
// 276
#include<bits/stdc++.h>
#define CLOSE ios::sync_with_stdio(false);cin.tie(0) , cout.tie(0);
using namespace std;
using ll=long long;
typedef pair<int,int> PII;
const int N=1e6+10;
char g[100][100];
int n , m;
int dir[4][2] = { {1,0}, {-1,0}, {0,1}, {0,-1} };
int ans;
int main()
{
CLOSE
n = 30 , m = 60;
for (int i = 1;i <= n;i++)
cin >> g[i] + 1;
for (int i = 1;i <= n;i++)
{
for (int j = 1;j <= m;j++)
{
int f = 1;
for (int k = 0,x,y;k < 4;k++)
{
x = i + dir[k][0];y = j + dir[k][1];
if (x<1 || x>n || y<1 || y>m)
{
f = 0;break;
}
}
if (f)
{
int h = 1;
for (int k = 0 , x , y;k < 4;k++)
{
x = i + dir[k][0];y = j + dir[k][1];
if (g[i][j] >= g[x][y])
{
h = 0;
break;
}
}
if (h)
{
ans++;
}
}
}
}
cout << ans;
return 0;
}
//最小矩阵
//12
#include<bits/stdc++.h>
#define CLOSE ios::sync_with_stdio(false);cin.tie(0) , cout.tie(0);
using namespace std;
using ll = long long;
typedef pair<int , int> PII;
const int N = 1e6 + 10;
int g[1010][1010];
ll sum[1010][1010];
int main()
{
CLOSE
int n = 100 , m = 100;
g[1][1] = 1;
for (int i = 1;i <= n;i++)
{
for (int j = 1;j <= m;j++)
{
if (i == 1 && j == 1)continue;
if (j == 1)g[i][j] = g[i - 1][j] + 1;
else g[i][j] = g[i][j - 1] + 1;
}
}
for (int i = 1;i <= n;i++)
{
for (int j = 1;j <= m;j++)
{
sum[i][j] = sum[i][j - 1] + sum[i - 1][j] - sum[i - 1][j - 1] + g[i][j];
}
}
for (int i = 1;i <= n;i++)
{
for (int j = 1;j <= m;j++)
{
for (int k = i ;k <= n;k++)
{
for (int z = j ;z <= m;z++)
{
int ans = sum[k][z] - sum[k][j - 1] - sum[i - 1][z] + sum[i - 1][j - 1];
if (ans == 2022)
{
cout << (k - i + 1) * (z - j + 1);
exit(0);
}
}
}
}
}
return 0;
}
//核算日期
//
#include<bits/stdc++.h>
#define CLOSE ios::sync_with_stdio(false);cin.tie(0) , cout.tie(0);
using namespace std;
using ll=long long;
typedef pair<int,int> PII;
const int N=1e6+10;
int s , t;
int ans;
int main()
{
CLOSE
cin >> s >> t;
ans = t - s;
if (ans < 0)ans += 7;
cout << ans;
return 0;
}
//英文转换
//toupper()函数
#include<bits/stdc++.h>
#define CLOSE ios::sync_with_stdio(false);cin.tie(0) , cout.tie(0);
using namespace std;
using ll=long long;
typedef pair<int,int> PII;
const int N=1e6+10;
string s;
bool jud(char x)
{
if (x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u')
return true;
return false;
}
int main()
{
CLOSE
cin >> s;
for (int i = 0;i < s.size();i++)
{
if (jud(s[i]))
{
s[i]=toupper(s[i]);
}
}
cout << s<<'\n';
return 0;
}
//充电器
//模拟 stoi函数和substr(string自带函数)
#include<bits/stdc++.h>
#define CLOSE ios::sync_with_stdio(false);cin.tie(0) , cout.tie(0);
using namespace std;
using ll=long long;
typedef pair<int,int> PII;
const int N=1e6+10;
int n;
string s;
ll ans;
int u , i;
//hh : mm : ss
int main()
{
CLOSE
cin >> n;
int la = 0;
int ui = 0;
while (n--)
{
cin >> s;
cin >> u >> i;
string hh , mm , ss;
hh = s.substr(0,2);
mm = s.substr(3,2);
ss = s.substr(6,2);
// cout << hh << " " << mm << " " << ss << '\n';
int now = stoi(hh) * 60 * 60 + stoi(mm) * 60 + stoi(ss);
int cha = now - la;
ans += cha * ui;
la = now;
ui = u * i;
}
cout << ans;
return 0;
}
//全等三角形
//大模拟
#include<bits/stdc++.h>
#define CLOSE ios::sync_with_stdio(false);cin.tie(0) , cout.tie(0);
using namespace std;
using ll=long long;
typedef pair<int,int> PII;
const int N=1e6+10;
int n , m;
char g[1010][1010];
// 上左 上右 下左 下右
int dx[4][2] = { {0,-1}, {-1,0}, {0,1} ,{1,0} };
int dy[4][2] = { {-1,0}, {0,1}, {-1,0}, {0,1} };
ll ans;
bool ch(int k,PII a,PII b)
{
int x = abs(a.first - b.first);
if (k == 0 || k == 3)
{
while (x)
{
x--;
if (g[--a.first][++a.second] != g[b.first][b.second])return false;
}
}
else
{
while (x)
{
x--;
if (g[++a.first][++a.second] != g[b.first][b.second])return false;
}
}
return true;
}
int jud(int x , int y)
{
int res = 0;
for (int k = 0;k < 4;k++)
{
for (int xa , ya , xb , yb,i=1;;i++)
{
xa = x + i*dx[k][0] , ya = y + i*dy[k][0];
xb = x + i * dx[k][1] , yb = y + i * dy[k][1];
if (g[xa][ya] != g[x][y] || g[xb][yb] != g[x][y])break;
if (xa<1 || xa>n || ya<1 || ya>m || xb<1 || xb>n || yb<1 || yb>m)break;
PII a = { xa,ya } , b = { xb,yb };
if (ch(k , a , b))res++;
}
}
return res;
}
int main()
{
CLOSE
cin >> n >> m;
for (int i = 1;i <= n;i++)
{
cin >> g[i] + 1;
}
for (int i = 1;i <= n;i++)
{
for (int j = 1;j <= m;j++)
{
ans += jud(i , j);
}
}
cout << ans;
return 0;
}
最后一题感觉是个贪心+找规律(不会)