結果

問題 No.3 ビットすごろく
ユーザー nyan68682154
提出日時 2019-05-15 08:21:20
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 495 bytes
コンパイル時間 458 ms
コンパイル使用メモリ 58,460 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-13 14:23:44
合計ジャッジ時間 1,484 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<string>
using namespace std;


int main() {
	int n;
	int masu = 1;
	int s = 0;
	int k;
	cin >> n;
	for (int i = 1; i <= 10000; i++) {

		if (masu == n) {
			cout << i ;
			break;
		}
		k = masu;
		for (int j = 1; j <= 20; j++) {
			s = k % 2 + s;
			k = k / 2 ;
			if (k == 0) {
				break;
			}
		}
		masu = s + masu;
		if (masu > n) {
			masu = masu - s*2;
		}
		s = 0;
		if (i == 10000) {
			cout << -1;
		}
	}
}
0