結果
| 問題 |
No.381 名声値を稼ごう Extra
|
| コンテスト | |
| ユーザー |
IL_msta
|
| 提出日時 | 2017-01-09 09:07:58 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,178 bytes |
| コンパイル時間 | 867 ms |
| コンパイル使用メモリ | 89,244 KB |
| 実行使用メモリ | 13,640 KB |
| 最終ジャッジ日時 | 2024-12-18 00:09:28 |
| 合計ジャッジ時間 | 10,072 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 TLE * 1 |
ソースコード
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <valarray>
/*
#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>
#include<cassert>//assert();
*/
#include <fstream>//ファイル操作
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define PII pair<int,int>
/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
/////////
using namespace::std;
/////////
/////////
#define ketaMax 9
ULL popcount(ULL b){
b -= (b >> 1) & 0x5555555555555555ULL;
b = ((b >> 2) & 0x3333333333333333ULL) + (b & 0x3333333333333333ULL);
b = ((b >> 4) + b) & 0x0F0F0F0F0F0F0F0FULL;
return (b * 0x0101010101010101ULL) >> 56;
}
int to_num(ULL* ans, string str){
int len = str.length();
string temp;
ULL pow10 = 1;
int pos = 0;
ans[0] = 0;
for(int i= 0;i<len;++i){
if((len-i)%ketaMax == 0 && i != 0){
++pos;
ans[pos] = 0;
}
temp = str[i];
ans[pos] = ans[pos]*10 +stoi( temp );
}
return pos+1;
}
struct vnum{
ULL num[1000000/ketaMax + 1];
int len;
ULL powMax;
ULL divNum;
int divShift;
void set(string str){
powMax = 1;
len = to_num(num, str);
powMax = (ULL)1000000000;
divNum = (ULL)17179869184;//(ULL)536870912;
divShift = 34;//29;
}
void div(){//
ULL ans = 0;
ULL ama = 0;
ULL mask = divNum-1;
int start = 0;
while( len != start ){
ULL temp;
for(int i=start; i < len;i++){//上の桁から
temp = powMax * ama + num[i];
num[i] = temp >> divShift; //商
ama = temp & mask;//あまり
}
ans += popcount(ama);
ama = 0;
if( num[start] == 0 ){
++start;
}
//cout << len << " " << start << " " << ans << "\r";
}
cout << ans << endl;
}
};
void solve(){
string str;
str.reserve(1000000);
vnum Num;
cin >> str;
Num.set(str);
Num.div();
}
int main(void){
std::cin.tie(0);
std::ios::sync_with_stdio(false);
std::cout << std::fixed;//
//cout << setprecision(16);//
solve();
return 0;
}
IL_msta