Links: https://ac.nowcoder.com/acm/contest/132/C?&headNav=www
Source: Cattle-off network
Simple messing around title
Time limit: C / C ++ 1 second, 2 seconds languages other
space restrictions: C / C ++ 32768K, other languages 65536k
64bit the IO the Format: LLD%
space restrictions: C / C ++ 32768K, other languages 65536k
64bit the IO the Format: LLD%
Title Description
There are a number n, is the i-th X i
X I can take [L I , R & lt I ] in an arbitrary value.
Set S = [Sigma X I 2 S = Σxi2, find the number of species S.Specific ideas:
bitset
00011 bitset represents the first such number exists, the second number is present (not binary).
Then every once in a calculation on the basis of adding just fine.
1 #include<bits/stdc++.h> 2 #include<bitset> 3 using namespace std; 4 # define ll long long 5 # define LL_inf (1ll<<60) 6 # define inf 0x3f3f3f3f3 7 const int maxn = 1e6+20; 8 const int mod = 1e9+7; 9 bitset<maxn>ans; 10 bitset<maxn>tmp; 11 int main() 12 { 13 int n; 14 scanf("%d",&n); 15 int st,ed; 16 ans[0]=1; 17 for(int i=1; i<=n; i++) 18 { 19 scanf("%d %d",&st,&ed); 20 tmp.reset(); 21 for(int j=st; j<=ed; j++) 22 { 23 tmp|=ans<<j*j; 24 } 25 ans=tmp; 26 } 27 cout<<ans.count()<<endl; 28 return 0; 29 }