結果
問題 |
No.791 うし数列
|
ユーザー |
![]() |
提出日時 | 2019-04-28 10:38:37 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,017 bytes |
コンパイル時間 | 1,043 ms |
コンパイル使用メモリ | 67,448 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-15 05:35:50 |
合計ジャッジ時間 | 1,458 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 9 WA * 6 |
ソースコード
#include<algorithm> #include<iostream> #include<stdio.h> #include<string> #include<vector> #include <cmath> #include <algorithm> #include <functional> using namespace std; typedef long long ll; int gcd(int m,int n) { // 引数に0がある場合は0を返す if ( ( 0 == m ) || ( 0 == n ) ) return 0; // ユークリッドの方法 while( m != n ) { if ( m > n ) m = m - n; else n = n - m; } return m; }//gcd int main(){ // input ll N; cin >>N; //vector<int> v(N); //std::sort(g.begin(),g.end()); ll ans = 0; ll out = -1; int flag = 1; while(flag != 0){ N = N-3; if(N % 10 == 0 && N >0){ N = N /10; ans++; }else { flag = 0; if(ans >0){ out = ans; } } if( N==1){ flag =0; out = ans; } if(N<=0){ out = -1; } } cout << out << endl; return 0; }