Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- */
- //#pragma comment(linker, "/STACK:16777216")
- #include <fstream>
- #include <iostream>
- #include <string>
- #include <complex>
- #include <math.h>
- #include <set>
- #include <vector>
- #include <map>
- #include <queue>
- #include <stdio.h>
- #include <stack>
- #include <algorithm>
- #include <list>
- #include <ctime>
- #include <memory.h>
- #include <ctime>
- #define y0 sdkfaslhagaklsldk
- #define y1 aasdfasdfasdf
- #define yn askfhwqriuperikldjk
- #define j1 assdgsdgasghsf
- #define tm sdfjahlfasfh
- #define lr asgasgash
- #define eps 1e-11
- //#define M_PI 3.141592653589793
- #define bs 1000000007
- #define bsize 256
- #define right adsgasgadsg
- #define free adsgasdg
- using namespace std;
- unsigned long bits[1<<18];
- long n,m,a,b;
- unsigned long ing[1<<12][1<<8];
- unsigned long outg[1<<12][1<<8];
- long c,both;
- long long ans;
- long gb(unsigned long x)
- {
- return bits[x>>16]+bits[x&65535];
- }
- int main(){
- //freopen("billing.in","r",stdin);
- //freopen("billing.out","w",stdout);
- //freopen("C:/input.txt","r",stdin);
- //freopen("C:/output.txt","w",stdout);
- ios_base::sync_with_stdio(0);
- //cin.tie(0);
- for (int i=0;i<=66666;i++)
- bits[i]=bits[i/2]+i%2;
- cin>>n>>m;
- unsigned long one=1;
- for (int i=0;i<m;i++)
- {
- a=rand()%n+1;
- b=rand()%n+1;
- //cin>>a>>b;
- outg[a][b/32]|=(one<<(b%32));
- ing[b][a/32]|=(one<<(a%32));
- }
- for (int c=1;c<=n;c++)
- {
- for (int a=1;a<=n;a++)
- if (c!=a)
- {
- b=0;
- for (int j=0;j<=n/32;j++)
- {
- b+=gb(ing[c][j]&outg[a][j]);
- }
- ans+=b*(b-1)/2;
- }
- }
- cout<<ans<<endl;
- cin.get();cin.get();
- return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement