cpp
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<vector>
#include<list>
#include<deque>
#define int long long
#define x first
#define y second
using namespace std;
const int N=2e5+5,INF=0x3f3f3f3f,mod=1000000007;
typedef long long LL;
typedef pair<int,int>PII;
signed main()
{
cout<<2*9*9*9+2*9+2;
return 0;
}
答案:1478
cpp
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<vector>
#include<list>
#include<deque>
#define int long long
#define x first
#define y second
using namespace std;
const int N=2e5+5,INF=0x3f3f3f3f,mod=1000000007;
typedef long long LL;
typedef pair<int,int>PII;
const int months[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
bool check(string str){
for(int i=0;i+2<str.size();i++)
if(str[i+1]==str[i]+1&&str[i+2]==str[i]+2)
return true;
return false;
}
signed main()
{
int year=2022,month=1,day=1;
int res=0;
for(int i=0;i<365;i++){
char str[10];
sprintf(str,"%04d%02d%02d",year,month,day);
if(check(str)){
res++;
cout<<str<<endl;
}
if(++day>months[month]){
day=1;
month++;
}
}
cout<<res;
return 0;
}//本题012也算顺子日期
答案:14
cpp
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<vector>
#include<list>
#include<deque>
#define int long long
#define x first
#define y second
using namespace std;
const int N=2e5+5,INF=0x3f3f3f3f,mod=1000000007;
typedef long long LL;
typedef pair<int,int>PII;
int a,b,n;
signed main()
{
cin>>a>>b>>n;
int s=5*a+2*b;
int res=n/s*7;
n%=s;
int d[]={a,a,a,a,a,b,b};
for(int i=0;n>0;i++){//n>0表示题目还没做完
n-=d[i];
res++;
}
cout<<res;
return 0;
}
cpp
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<vector>
#include<list>
#include<deque>
#define int long long
#define x first
#define y second
using namespace std;
const int N=10010,INF=0x3f3f3f3f,mod=1000000007;
typedef long long LL;
typedef pair<int,int>PII;
signed main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++){
cout<<max(i-1,n-i)*2<<endl;
}
return 0;
}
cpp
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<vector>
#include<list>
#include<deque>
#define int long long
#define x first
#define y second
using namespace std;
const int N=100010,INF=0x3f3f3f3f,mod=1000000007;
typedef long long LL;
typedef pair<int,int>PII;
int n,ma,mb;
int ans;
int nums[100001];
signed main()
{
memset(nums,0,sizeof nums);
cin>>n>>ma;
for(int i=0;i<ma;i++) cin>>nums[i];
cin>>mb;
for(int i=0;i<ma;i++){
int val=0;
if(mb+i>=ma) cin>>val;
ans*=max(max(nums[i],val)+1,(LL)2);
ans+=(nums[i]-(LL)val);
ans%=mod;
}
cout<<ans;
return 0;
}
cpp
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<vector>
#include<list>
#include<deque>
#define int long long
#define x first
#define y second
using namespace std;
const int N=510,INF=0x3f3f3f3f,mod=1000000007;
typedef long long LL;
typedef pair<int,int>PII;
int n,m,k;
int s[N][N];//表示每一列上的一维前缀和
signed main()
{
cin>>n>>m>>k;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
cin>>s[i][j];
s[i][j]+=s[i-1][j];
}
int res=0;
for(int i=1;i<=n;i++)
for(int j=i;j<=n;j++)
for(int l=1,r=1,sum=0;r<=m;r++){
sum+=s[j][r]-s[i-1][r];
while(sum>k){
sum-=s[j][l]-s[i-1][l];
l++;
}
res+=r-l+1;
}
cout<<res;
return 0;
}//双指针,前缀和
cpp
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<vector>
#include<list>
#include<deque>
#define int long long
#define x first
#define y second
using namespace std;
const int N=1e7+10,INF=0x3f3f3f3f,mod=1e9+7,M=10;
typedef long long LL;
typedef pair<int,int>PII;
int dp[2][3];
signed main()
{
int n;
cin >> n;
dp[1][0] = 1;
dp[1][1] = 2;
dp[1][2] = 1;
for(int i = 2; i <= n; i++) {
dp[i&1][0] = (dp[i-1&1][0] + dp[i-1&1][2]) % mod;
dp[i&1][1] = (dp[i-1&1][0] * 2 + dp[i-1&1][1]) % mod;
dp[i&1][2] = (dp[i-1&1][0] + dp[i-1&1][1]) % mod;
}
cout << dp[n&1][0];
return 0;
}
cpp
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<vector>
#include<list>
#include<deque>
#define int long long
#define x first
#define y second
using namespace std;
const int N=50010,INF=0x3f3f3f3f,mod=1e9+7,M=999997;
typedef long long LL;
typedef pair<int,int>PII;
int n,m;
struct circle{
int x,y,r;
}cir[N];
int h[M];
int id[M];
bool st[M];
LL get_key(int x,int y){
return x*1000000001ll+y;
}
int find(int x,int y){
int key=get_key(x,y);
int t=(key%M+M)%M;
while(h[t]!=-1&&h[t]!=key)
if(++t==M)
t=0;
return t;
}//手写哈希表
int sqr(int x){
return x*x;
}
void dfs(int x,int y,int r){
st[find(x,y)]=true;
for(int i=x-r;i<=x+r;i++)
for(int j=y-r;j<=y+r;j++)
if(sqr(i-x)+sqr(j-y)<=sqr(r)){
int t=find(i,j);
if(id[t]&&!st[t])
dfs(i,j,cir[id[t]].r);
}
}
signed main()
{
cin>>n>>m;
memset(h,-1,sizeof h);
for(int i=1;i<=n;i++){
int x,y,r;
cin>>x>>y>>r;
cir[i]={x,y,r};
int t=find(x,y);
if(h[t]==-1) h[t]=get_key(x,y);
if(!id[t]||cir[id[t]].r<r)
id[t]=i;
}
while(m--){
int x,y,r;
cin>>x>>y>>r;
for(int i=x-r;i<=x+r;i++)
for(int j=y-r;j<=y+r;j++)
if(sqr(i-x)+sqr(j-y)<=sqr(r))
{
int t=find(i,j);
if(id[t]&&!st[t])
dfs(i,j,cir[id[t]].r);
}
}
int res=0;
for(int i=1;i<=n;i++)
if(st[find(cir[i].x,cir[i].y)])
res++;
cout<<res;
return 0;
}//哈希
cpp
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<vector>
#include<list>
#include<deque>
#define int long long
#define x first
#define y second
using namespace std;
const int N=110,INF=0x3f3f3f3f,mod=1e9+7,M=999997;
typedef long long LL;
typedef pair<int,int>PII;
int n,m;
int f[N][N][N];
signed main()
{
cin>>n>>m;
f[0][0][2]=1;
for(int i=0;i<=n;i++)
for(int j=0;j<=m;j++)
for(int k=0;k<=m;k++){
int &v=f[i][j][k];
if(i&&k%2==0) v=(v+f[i-1][j][k/2])%mod;
if(j) v=(v+f[i][j-1][k+1])%mod;
}
cout<<f[n][m-1][1];
return 0;
}
cpp
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<vector>
#include<list>
#include<deque>
#define int long long
#define x first
#define y second
using namespace std;
const int N=2e5+5,INF=0x3f3f3f3f,mod=1e9+7,M=10;
typedef long long LL;
typedef pair<int,int>PII;
int n,m;
int f[N][M];
signed main()
{
cin>>n;
int stk[M];
int res=0;
for(int i=0;i<n;i++){
int x;
int top=0;
cin>>x;
while(x>1) stk[++top]=x,x=sqrt(x/2+1);
res+=top;
m=max(m,top);
for(int j=0,k=top;k;j++,k--)
f[i][j]=stk[k];
}
for(int i=0;i<m;i++)
for(int j=1;j<n;j++)
if(f[j][i]&&f[j][i]==f[j-1][i])
res--;
cout<<res;
return 0;
}