刷题统计
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
LL a,b,n;
int main()
{
cin>>a>>b>>n;
LL sum=5*a+2*b;
LL p=n/sum;//几周
LL q=n%sum;//剩余的题数
//整数的天数
LL sum1=p*7;
LL sum2=p*sum;//当前的做题数
if(q==0)
{
cout<<sum1;
return 0;
}
for(int i=1;i<=7;i++)
{
if(i<=5)
{
if(a>=q)
{
sum1++;
break;
}
q-=a;
sum1++;
}else
{
if(b>=q)
{
sum1++;
break;
}
q-=b;
sum1++;
}
}
cout<<sum1;
return 0;
}
接龙数列:线性DP
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1e8+10;
int g[10];
int f[N];
int main()
{
int n;
cin>>n;
char s[20];
int l;
int r;
int res=0;
for(int i=1;i<=n;i++)
{
cin>>s;
l=s[0]-'0';//记录第一个数
r=s[strlen(s)-1]-'0';//记录数组的最后一个数
f[i]=max(f[i],g[l]+1);
g[r]=max(f[i],g[r]);
//表示的是以l结尾的前i个数,以l结尾的最大的一个数的和
// dp[r]=max(dp[l]+1,dp[r]);//记录的是最后的数以l结尾的数的最大值
// cout<<dp[r]<<endl;
}
for(int i=1;i<=n;i++)
{
res=max(res,f[i]);
}
cout<<n-res;
return 0;
}
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int arr[10];
int p=0;
int sum=0;
int main()
{
for(int i=1;i<=2020;i++)
{
int n=i;
while(n)
{
p=n%10;
if(p==2)
{
sum++;
}
n/=10;
}
}
cout<<sum;
return 0;
}
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
/*
1 2 6 7 15 ...
3 5 8 14 ...
4 9 13 ...
10 12 ...
11 ...
...
分析可得:
第一行第一列 0*0+1*1
第二行第二列 1*1+2*2
第三行第三列 2*2+3*3
一次类推
*/
cout<<19*19+20*20<<endl;
return 0;
}
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int gcp(int a,int b)
{
//求最大公约数
return b?gcp(b,a%b):a;
}
int sum=0;
int x,y;
int main()
{
for(int i=1;i<=2020;i++)
{
for(int j=1;j<=2020;j++)
{
//首先有i做分母
if(gcp(i,j)==1)
{
sum++;
}
}
}
cout<<sum;
return 0;
}