PhieuLang

Lovely Doll

May 21st, 2012
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include<fstream>
  2. #include<iostream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     ifstream fi("SHOP.INP");
  8.     ofstream fo("SHOP.OUT");
  9.     int i, n, k, total = 0;
  10.     fi>>n>>k;
  11.     int a[n];
  12.     for(i=0;i<n;i++)
  13.         fi>>a[i];
  14.     for(i=0;i<n;i++)
  15.         if(!(i%(n/k)))
  16.             total += a[i];
  17.     fo<<"Gia tien "<<total<<endl;
  18.     cout<<total<<endl;
  19.     fi.close();
  20.     fo.close();
  21. }
Advertisement
Add Comment
Please, Sign In to add comment