Advertisement
Guest User

Untitled

a guest
Nov 18th, 2014
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. /*
  2. */
  3.  
  4. //#pragma comment(linker, "/STACK:16777216")
  5. #include <fstream>
  6. #include <iostream>
  7. #include <string>
  8. #include <complex>
  9. #include <math.h>
  10. #include <set>
  11. #include <vector>
  12. #include <map>
  13. #include <queue>
  14. #include <stdio.h>
  15. #include <stack>
  16. #include <algorithm>
  17. #include <list>
  18. #include <ctime>
  19. #include <memory.h>
  20. #include <ctime>
  21.  
  22. #define y0 sdkfaslhagaklsldk
  23. #define y1 aasdfasdfasdf
  24. #define yn askfhwqriuperikldjk
  25. #define j1 assdgsdgasghsf
  26. #define tm sdfjahlfasfh
  27. #define lr asgasgash
  28.  
  29. #define eps 1e-11
  30. //#define M_PI 3.141592653589793
  31. #define bs 1000000007
  32. #define bsize 256
  33. #define right adsgasgadsg
  34. #define free adsgasdg
  35.  
  36. using namespace std;
  37.  
  38. unsigned long bits[1<<18];
  39. long n,m,a,b;
  40. unsigned long ing[1<<12][1<<8];
  41. unsigned long outg[1<<12][1<<8];
  42. long c,both;
  43. long long ans;
  44.  
  45. long gb(unsigned long x)
  46. {
  47. return bits[x>>16]+bits[x&65535];
  48. }
  49.  
  50. int main(){
  51. //freopen("billing.in","r",stdin);
  52. //freopen("billing.out","w",stdout);
  53. //freopen("C:/input.txt","r",stdin);
  54. //freopen("C:/output.txt","w",stdout);
  55. ios_base::sync_with_stdio(0);
  56. //cin.tie(0);
  57.  
  58. for (int i=0;i<=66666;i++)
  59. bits[i]=bits[i/2]+i%2;
  60.  
  61. cin>>n>>m;
  62.  
  63. unsigned long one=1;
  64.  
  65. for (int i=0;i<m;i++)
  66. {
  67. a=rand()%n+1;
  68. b=rand()%n+1;
  69. //cin>>a>>b;
  70.  
  71. outg[a][b/32]|=(one<<(b%32));
  72. ing[b][a/32]|=(one<<(a%32));
  73. }
  74.  
  75. for (int c=1;c<=n;c++)
  76. {
  77. for (int a=1;a<=n;a++)
  78. if (c!=a)
  79. {
  80. b=0;
  81. for (int j=0;j<=n/32;j++)
  82. {
  83. b+=gb(ing[c][j]&outg[a][j]);
  84. }
  85. ans+=b*(b-1)/2;
  86. }
  87. }
  88.  
  89. cout<<ans<<endl;
  90.  
  91. cin.get();cin.get();
  92. return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement