sprintf 和 ++ d 的用法
#include
using namespace std;
const int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
char str[10];
int res = 0 ;
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 ;
}
int main(int argc, char *avgv[])
{
int y = 2022 , m= 1 , d = 1;
for(int i = 0 ; i < 365 ; i++)
{
sprintf(str,"%04d%02d%02d",y,m ,d);
if(check(str))
{
res ++ ;
}
if(++ d > month[m])
{
d = 1 ;
m ++ ;
}
}
cout << res;
return 0;
}
点击跳转至acwing对应题
自己做的(样例过了7个,7/11)
#include
using namespace std;
typedef long long int LL ;
LL a,b,n;
int main()
{
cin >> a >> b >> n;
LL t = 0 , res = 0;
LL s = max(n/a,n/b);
for(int i = 1 ; i <= s ; i++ )
{
int j = i % 7 ;
if(j <= 5 && j != 0)t += a ;
else t += b ;
if(t >= n)
{
cout << i << endl;
break;
}
}
return 0;
}
y总的思路,特别清晰!!!
#include
using namespace std;
typedef long long LL ;
LL a,b,n;
int main(int argc, char *avgv[])
{
cin >> a >> b >> n;
LL s = 5 * a + 2 * b ;
LL res = (n / s) * 7 ;
n %= s ;
LL d[] = {a,a,a,a,a,b,b};
for(int i = 0 ; n > 0 ; i++)
{
n -= d[i];
res ++ ;
}
cout << res << endl;
return 0;
}
点击跳转至题目
自己做没做出来qwq
想到这一点了,不过想的多了,还想了回来的情况,就懵逼了
直接看i这个点的情况,厉害
我憨批了 qwq
#include
#include
#include
using namespace std ;
int main()
{
int n ;
cin >> n ;
int res ;
for(int i = 1 ; i <=n ; i++)
{
res = max(n-i , i-1) * 2 ;
cout << res << endl ;
}
return 0 ;
}
#include
#include
#include
typedef long long LL ;
using namespace std;
const int N = 1e6 + 10 , MOD = 1000000007;
int n ;
int n1, n2 ;
int a[N],b[N];
int main()
{
cin >> n;
cin >> n1 ;
for(int i = n1 - 1 ; i >= 0 ; i--) cin >> a[i];
cin >> n2;
for(int i = n2 - 1; i >= 0 ; i--) cin >> b[i];
int s = max(n1,n2);
int res = 0 ;
for(int i = s - 1; i >= 0 ; i--)
{
res = (res * (LL) max({a[i] + 1 , b[i] + 1 , 2}) + a[i] - b[i]) % MOD;
}
cout << res;
return 0;
}
#include
using namespace std;
typedef long long LL;
const int N = 510;
LL f[N][N];
int n , m ;
LL k;
int main()
{
cin >> n >> m >> k ;
for(int i = 1 ; i <= n ; i++)
{
for(int j = 1 ; j <= m ; j++)
{
cin >> f[i][j] ;
f[i][j] += f[i-1][j];
}
}
LL 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 += f[j][r] - f[i-1][r];
while(sum > k)
{
sum -= f[j][l] - f[i-1][l];
l++;
}
res += r - l + 1;
}
}
}
cout << res;
return 0;
}
后面做的题没时间记录思路了哈哈,就这样结束吧
2023/4/7/21:41