SHARE
TWEET

Untitled

a guest May 15th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int X, Y, N;
  7.    
  8.     // 輸入
  9.     cin >> X >> Y >> N;
  10.    
  11.     // 準備好循環的內容
  12.     int p[6] = {X, Y, Y - X, -X, -Y, X - Y};
  13.     // 計算第N項落在循環中的第幾項
  14.     int ans = p[(N - 1) % 6] % (int)(1e9 + 7);
  15.    
  16.     // 輸出,是負數的話要加回正數
  17.     cout << (ans < 0 ? ans + (int)(1e9 + 7) : ans) << endl;
  18.  
  19.     return 0;
  20. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top