#include
using namespace std;
int main(){
cout<<2 * 9 * 9 * 9 + 2 * 9 + 2 ;
return 0 ;
}
答案:1478
题意, 呃…… 按照我理解 …… 14
#include
using namespace std;
int mo[] = {31, 28,31,30,31,30,31,31,30,31,30,31};
int main(){
int res = 0 ;
for(int i = 1 ; i <= 12 ; i ++ ) {
string str = "2022" ;
int z = i ;
if(z < 10 ) str+= '0' ;
else str += (z /10 ) +'0' ;
str += (z % 10 ) +'0' ;
for(int j = 1 ; j <= mo[i - 1 ] ; j ++ ) {
string a ;
int z = j ;
while(z) {
a+=(z % 10 )+'0' ;
z /=10 ;
}
while(a.size() < 2 ) a += '0' ;
reverse(a.begin() , a.end()) ;
a = str + a ;
for(int z = 0 ; z < a.size() - 2; z ++ ) {
if(a[z+ 1 ] == (a[z] + 1) && a[z + 2 ] == (a[z] + 2) ) {
res ++ ;
cout<
#include
using namespace std ;
int main(){
long long a , b , n ;
cin>>a >>b >> n ;
long long z = a * 5 + b * 2 ;
long long t = n / z * 7 ;
n %= z;
for(int i = 1 ; i <= 5 ; i ++ ) {
if(n > 0 ) {
t ++ ;
n-=a;
}else{
cout< 0 ) {
t ++ ;
n-=b;
}else{
cout<
打表找规律
#include
using namespace std ;
int main(){
int n ;
cin>> n ;
int k = (n - 1 ) * 2 ;
for(int i = 1 ; i <= n / 2 ; i ++ ) {
cout<< k <<"\n" ;
k -= 2 ;
}
if(n % 2 == 1 ) cout << k <<"\n" ;
k +=2 ;
for(int i = 1 ; i <= n / 2 ; i ++ ) {
cout<< k <<"\n" ;
k+=2 ;
}
return 0 ;
}
读懂题就会了
#include
using namespace std;
const int N = 101000 ;
long long a[N], b[N] ;
long long mod = 1000000007 ;
int main(){
int n ;
cin>>n;
int lena ;
cin>>lena ;
for(int i = lena ; i >=1 ; i -- ) {
cin>>a[i] ;
}
int lenb ;
cin>>lenb ;
for(int i = lenb ; i >= 1 ; i -- ) {
cin>>b[i] ;
}
long long res = 0 , ba= 1 ;
for(int i = 1 ; i <= max(lena , lenb); i ++ ) {
int maxx = max(a[i] , b[i]) + 1 ;
maxx = max(maxx , 2 ) ;
res += a[i] * ba ;
res %= mod ;
res = (res + mod - b[i] * ba) % mod ;
ba *= maxx ;
ba %= mod ;
}
cout<<(res + mod) % mod<<"\n" ;
return 0 ;
}
对于 30% 的数据,N, M ≤ 20.
对于 70% 的数据,N, M ≤ 100.
对于 100% 的数据,1 ≤ N, M ≤ 500; 0 ≤ A**i j ≤ 1000; 1 ≤ K ≤ 250000000
比赛暴力拿的前百分之七十的分
正解待补
#include
using namespace std;
const int N = 510 ;
long long a[N][N] , b[N][N];
int main(){
long long n , m , k ;
cin>>n >>m >> k ;
for(int i = 1 ; i <= n ; i ++ ) {
for(int j = 1 ; j <= m ; j ++ ) {
cin>>a[i][j] ;
}
}
for(int i = 1 ; i <= n ; i ++ ) {
for(int j = 1 ; j <= m ; j ++ ) {
b[i][j] = b[i - 1][j] + b[i][j - 1 ] - b[i - 1][j - 1 ] + a[i][j] ;
}
}
int res = 0 ;
for(int i = 1 ; i <= n ; i ++ ) {
for(int j = 1 ; j <= m ; j ++ ) {
for(int ii = 1 ; ii <= i ; ii ++ ){
for(int jj = 1 ; jj <= j ; jj ++ ) {
if(b[i][j] - b[i][jj - 1 ] - b[ii - 1][j] + b[ii - 1][jj - 1 ] <= k) res ++ ;
}
}
}
}
cout<
对于 40% 的评测用例:1 ≤ N, M ≤ 10。
对于 100% 的评测用例:1 ≤ N, M ≤ 100
比赛的时候二进制枚举拿的百分之四十的分
正解待补
#include
using namespace std;
int main(){
int n , m ;
cin>>n >> m ;
int res = 0 ;
for(int i = 0 ; i < (1 << (n + m )) ; i ++ ) {
int now = 2 , a = 0 , b = 0 , ok = 1;
for(int j = 0 ; j < (n + m ); j ++ ) {
if(i >> j & 1 ) a ++ , now *= 2 ;
else {
b ++ ;
if(now == 0 ) {
ok = 0;break ;
}
else now -- ;
}
}
// cout<> (n + m - 1)) == 0 ) ) {
res ++ ;
}
}
cout<
线段树
#include
using namespace std;
#define int long long
const int N = 2e5+10;
int h[N] ;
struct node{
int l , r , maxx , la;
}tr[N * 4 ];
void push_up(int u ) {
tr[u].maxx= max(tr[u << 1].maxx , tr[u << 1 | 1].maxx) ;
}
void build(int u , int l , int r ) {
tr[u] = {l , r } ;
if(l == r ) {
tr[u].maxx = h[l] ;
return ;
}
int mid = l + r >> 1 ;
build(u << 1 , l , mid ) ;
build(u << 1 | 1 , mid + 1 , r );
push_up(u) ;
}
void push_down(int u){
int &la = tr[u].la ;
if(la != 0) {
node &l = tr[u << 1 ] , &r = tr[u << 1 | 1 ] ;
l.maxx = r.maxx = l.la = r.la = la;
la = 0 ;
}
}
int query(int u , int x ) {
if(tr[u].l == tr[u].r ) {
return tr[u].l ;
}
push_down(u) ;
if(tr[u << 1].maxx == x ) return query(u << 1 , x ) ;
else return query(u << 1 | 1 , x ) ;
}
void modify(int u , int l , int r , int z ) {
if(tr[u].l >= l && tr[u].r <= r ) {
tr[u].la = tr[u].maxx = z ;
return ;
}
push_down(u) ;
int mid = tr[u].l + tr[u].r >> 1 ;
if(l <= mid ) modify(u << 1 , l , r , z ) ;
if(mid < r ) modify(u << 1 | 1 , l , r ,z ) ;
push_up(u) ;
}
signed main(){
int n ;
cin>>n;
for(int i = 1 ; i<= n ;i ++ ) cin>>h[i] ;
build(1 , 1 , n ) ;
int res = 0 ;
while(tr[1].maxx != 1 ) {
res ++ ;
int maxx = tr[1].maxx;
int l = query(1 , maxx) ;
int r = l ;
int ch = maxx / 2 + 1 ;
ch = sqrt(ch) ;
while(h[r] == maxx ) r ++ ;
r -- ;
for(int i = l ; i <= r ; i ++ ) h[i] = ch ;
modify(1 , l , r , ch ) ;
}
cout<
这次蓝桥打的比去年好太多了,菜鸟哭泣, 拿了个省一, 本省14