题目链接:http://codeforces.com/contest/1139
#include
using namespace std;
#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define root l,r,rt
#define mst(a,b) memset((a),(b),sizeof(a))
#define pii pair
#define fi first
#define se second
#define mk(x,y) make_pair(x,y)
const int mod=1e9+7;
const int maxn=7e4+5;
const int ub=1e6;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
char s[maxn];
int n;
ll ans=0;
int main(){
scanf("%d%s",&n,s);
rep(i,0,n) if((s[i]-'0')%2==0)
ans+=i+1;
printf("%lld\n",ans);
return 0;
}
#include
using namespace std;
#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define root l,r,rt
#define mst(a,b) memset((a),(b),sizeof(a))
#define pii pair
#define fi first
#define se second
#define mk(x,y) make_pair(x,y)
const int mod=1e9+7;
const int maxn=5e5+5;
const int ub=1e6;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
ll n,a[maxn],ans=0,pre;
int main(){
cin>>n;
rep(i,1,n+1) cin>>a[i];pre=1e9+9;
for(int i=n;i>=1;i--){
pre=max(0LL,min(a[i],pre-1));
ans+=pre;
}
cout<
#include
using namespace std;
#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define root l,r,rt
#define mst(a,b) memset((a),(b),sizeof(a))
#define pii pair
#define fi first
#define se second
#define mk(x,y) make_pair(x,y)
const int mod=1e9+7;
const int maxn=2e5+5;
const int ub=1e6;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
ll n,k;
struct node{
int u,nxt,v;
}e[maxn<<1];
int head[maxn],tot=0;
void add(int x,int y,int z){
e[tot]=node{y,head[x],z};
head[x]=tot++;
}
ll cnt[maxn];
int vis[maxn];
int dfs(int u,int pre){
vis[u]=1;
int ret=1;
for(int i=head[u];~i;i=e[i].nxt){
int v=e[i].u;
if(v==pre) continue;
ret+=dfs(v,u);
}
return ret;
}
ll ans=0;
int main(){
mst(head,-1),tot=0,mst(cnt,0);///cout<>n>>k;
rep(i,1,n){
int x,y,z;
cin>>x>>y>>z;
if(z==1) continue;
add(x,y,z),add(y,x,z);
}
ans=powmod(n,k);
rep(i,1,n+1)if(vis[i]==0){
ans=(ans-powmod(dfs(i,0),k)+mod)%mod;
}
cout<
#include
using namespace std;
#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define root l,r,rt
#define mst(a,b) memset((a),(b),sizeof(a))
#define pii pair
#define fi first
#define se second
#define mk(x,y) make_pair(x,y)
const int mod=1e9+7;
const int maxn=1e5+5;
const int ub=1e6;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*
题目大意:
*/
int m,prim[maxn],tot=0;
int vis[maxn],miu[maxn];
void sieve(){
miu[1]=1;
for(int i=2;i<=m;i++){
if(vis[i]==0) prim[tot++]=i,miu[i]=1;
for(int j=0;jm) break;
int tp=i*prim[j];vis[tp]=1;
if(i%prim[j]) miu[tp]=-miu[i];
else break;
}
}
}
int main(){
cin>>m;
sieve();
ll ans=1;
rep(i,2,m+1) if(miu[i]){
ans=(ans+miu[i]*(m/i)*powmod(m-m/i,mod-2)+mod)%mod;
}
cout<