Advertisement
rotti321

Camioane [Dirichlet]

May 23rd, 2017
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.06 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. int n,c[1000]={},rest[1000]={},r=0;
  5. ifstream f("camioane.in");
  6. ofstream g("camioane.out");
  7.  
  8. long long Pow(long long a, long long b,int n) {
  9.   long long ans = 1;
  10.  
  11.   while(b)
  12.     if(b & 1) ans *= a, ans %= n, --b;
  13.     else a *= a, a %= n, b /= 2;
  14.  
  15.   return ans;
  16. }
  17.  
  18. void constr(int c[],int n){
  19.     //c[]
  20. }
  21.  
  22. int main()
  23. {
  24.     int nr_inc, prima_inc;
  25.     f>>n;
  26.     for(int i=1;i<=n;i++){
  27.         f>>c[i];
  28.     }
  29.     for(int i=1;i<=n;i++){
  30.         r = (r+c[i])%n;  ///sume part
  31.       ///  cout<<i<<" r="<<r<<endl;
  32.         if(r==0){
  33.             for(int k=1;k<=i;++k){
  34.                 g<<k<<" ";
  35.                 return 0;
  36.             }
  37.         }
  38.         else{
  39.             if(rest[r]!=0){
  40.                 nr_inc =i-rest[r];
  41.                 prima_inc =rest[r]+1;
  42.                 for(int j=1;j<=nr_inc;j++){
  43.                     g<<prima_inc + j -1<<" ";
  44.                 }
  45.                 return 0;
  46.             }
  47.             else{
  48.                 rest[r]=i;
  49.             }
  50.         }
  51.     }
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement