4.3w+
社区成员
目录
#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <set>
#define x first
#define y second
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
typedef pair<int,int> PII;
typedef pair<char,int> PCI;
typedef long long LL;
//typedef __int128 i128;
typedef unsigned long long ULL;
const int N=4e5+10,INF = 0x3f3f3f3f ;
const double eps = 1e-7;
LL res= 0;
int cnt(int x)
{
int c=0,t;
while(x)
{
t = x % 10;x/=10;
if(t == 2 ) c ++ ;
}
return c;
}
int main()
{
for(int i=1;i<=2020;i ++ )
{
res += cnt(i);
}
cout << res <<endl;
return 0;
}
#include <iostream>
#include <bits/stdc++.h>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#define x first
#define y second
#define endl '\n'
#define ms(x,y) memset(x,y,sizeof x)
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
typedef pair<char,int> PCI;
typedef pair<string,int> PSI;
typedef pair<int,string> PIS;
typedef pair<LL,LL> PLL;
//typedef __int128 i128;
typedef unsigned long long ULL;
const int N= 20000 + 10,M = 55 ;
const int INF = 0x3f3f3f3f ,mod = 1e9 + 7 ,P = 131;
const double eps = 1e-7;
LL n = 2021041820210418;
LL cnt,p[N];
void solve()
{
for(LL i =1;i <= n/i;i ++ )
{
if(n % i == 0)
{
p[cnt ++ ] = i;
if(n/i != i )
{
p[cnt ++ ] = n/i;
}
}
}
LL res=0;
for(LL i=0;i<cnt ;i++ )
for(LL j=0;j<cnt;j ++ )
for(LL k= 0;k< cnt ;k ++ )
{
res += (p[i] * p[j] * p[k] == n );
}
cout << res <<endl;
}
signed main()
{
// freopen("1.txt","r",stdin);
int T=1;
// cin>>T;
int now = 1;
while(T -- )
{
// cout<<"Case ";
// cout<< now ++ <<": ";
solve();
}
return 0;
}
#include <iostream>
#include <bits/stdc++.h>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#define x first
#define y second
#define endl '\n'
#define ms(x,y) memset(x,y,sizeof x)
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
typedef pair<char,int> PCI;
typedef pair<string,int> PSI;
typedef pair<int,string> PIS;
typedef pair<LL,LL> PLL;
//typedef __int128 i128;
typedef unsigned long long ULL;
const int N= 100+ 10,M = 55 ;
const int INF = 0x3f3f3f3f ,mod = 1e9 + 7 ,P = 131;
const double eps = 1e-7;
int m,n,w[N][N],f[N][N];
void solve()
{
cin >> n >> m ;
for(int i=3;i<=n + 2 ;i ++ )
for(int j=3;j<=m +2; j ++ )
cin >> w[i][j];
ms(f,-0x3f);
f[3][3] = w[3][3];
for(int i=3;i<=n + 2 ;i ++ )
for(int j=3;j<=m +2; j ++ )
{
if(i == 3 && j == 3 ) continue;
int &t = f[i][j];
for(int x=1;x<=3 && i -x >= 3 ;x ++ )
{
t =max(t,f[i-x][j]);
}
for(int y=1;y <= 3 && j - y >= 3 ; y ++ )
{
t = max(t,f[i][j-y]);
}
t += w[i][j];
}
cout << f[n + 2 ][m + 2 ] <<endl;
}
signed main()
{
// freopen("1.txt","r",stdin);
int T=1;
// cin>>T;
int now = 1;
while(T -- )
{
// cout<<"Case ";
// cout<< now ++ <<": ";
solve();
}
return 0;
}
#include <iostream>
#include <bits/stdc++.h>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#define x first
#define y second
#define endl '\n'
#define ms(x,y) memset(x,y,sizeof x)
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
typedef pair<char,int> PCI;
typedef pair<string,int> PSI;
typedef pair<int,string> PIS;
typedef pair<LL,LL> PLL;
//typedef __int128 i128;
typedef unsigned long long ULL;
const int N= 100+ 10,M = 55 ;
const int INF = 0x3f3f3f3f ,mod = 1e9 + 7 ,P = 131;
const double eps = 1e-7;
LL n,m,a[N],s[N],b[N],c[N];
LL s1,s2,res;
void solve()
{
cin >> n;
for(int i=1;i <= n; i++ )cin >> a[i],s[i] = s[i-1] + a[i];
cin >> m;
while(m--)
{
int l,r;cin >> l >> r;
b[l] ++ ,b[r + 1] --;
s1 += s[r] - s[l-1];
}
for(int i=1;i<= n;i ++ ) c[i] = c[i-1] + b[i];
sort(c + 1, c + n + 1);// 将每个数的出现次数排序
sort(a + 1, a + n + 1);// 将原来每个数大小排序
for(int i=1;i<=n;i ++ )
{
s2 += c[i] * a[i];
// 重新分配每个数出现的次数 ,数值小的出现次数少,数值大的出现次数多
}
cout << s2 - s1 << endl;
}
signed main()
{
// freopen("1.txt","r",stdin);
int T=1;
// cin>>T;
int now = 1;
while(T -- )
{
// cout<<"Case ";
// cout<< now ++ <<": ";
solve();
}
return 0;
}