結果
問題 | No.381 名声値を稼ごう Extra |
ユーザー | IL_msta |
提出日時 | 2017-01-09 19:48:05 |
言語 | C++11 (gcc 11.4.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 4,369 bytes |
コンパイル時間 | 616 ms |
コンパイル使用メモリ | 68,084 KB |
実行使用メモリ | 13,984 KB |
最終ジャッジ日時 | 2024-05-10 03:28:27 |
合計ジャッジ時間 | 10,077 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | TLE | - |
ソースコード
//#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> ///////// //#define mygc(c) (c)=getchar_unlocked() ///////// typedef long long LL; typedef long double LD; typedef unsigned long long ULL; ///////// using namespace::std; ///////// int reader(char c[]){ int i,s=0; for(;;){ //mygc(i); //i = getchar_unlocked(); i = getchar(); if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break; }c[s++]=i; for(;;){ //mygc(i); //i = getchar_unlocked(); i = getchar(); if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break; c[s++]=i; }c[s]='\0';return s; } ///////// #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)4294967296;//(ULL)17179869184;//(ULL)536870912; divShift = 32;//34;//29; } void div(){// ULL ans = 0; //ULL mask = divNum-1; ULL ama = 0; int start = 0; while( start < len ){ ULL temp; ama = 0; long i; for(i=start; i < len-15;i+=16){//上の桁から temp = num[i] + ama * 1000000000;//temp = num[i] + ama * powMax; num[i] = temp >> 32; //商//num[i] = temp >> divShift; //商 ama = temp & 0xFFFFFFFF;//あまり temp = num[i+1] + ama * 1000000000; num[i+1]= temp >> 32; ama = temp & 0xFFFFFFFF; temp = num[i+2] + ama * 1000000000; num[i+2]= temp >> 32; ama = temp & 0xFFFFFFFF; temp = num[i+3] + ama * 1000000000; num[i+3]= temp >> 32; ama = temp & 0xFFFFFFFF; temp = num[i+4] + ama * 1000000000; num[i+4]= temp >> 32; ama = temp & 0xFFFFFFFF; temp = num[i+5] + ama * 1000000000; num[i+5]= temp >> 32; ama = temp & 0xFFFFFFFF; temp = num[i+6] + ama * 1000000000; num[i+6]= temp >> 32; ama = temp & 0xFFFFFFFF; temp = num[i+7] + ama * 1000000000; num[i+7]= temp >> 32; ama = temp & 0xFFFFFFFF; temp = num[i+8] + ama * 1000000000; num[i+8]= temp >> 32; ama = temp & 0xFFFFFFFF; temp = num[i+9] + ama * 1000000000; num[i+9]= temp >> 32; ama = temp & 0xFFFFFFFF; temp = num[i+10] + ama * 1000000000; num[i+10]= temp >> 32; ama = temp & 0xFFFFFFFF; temp = num[i+11] + ama * 1000000000; num[i+11]= temp >> 32; ama = temp & 0xFFFFFFFF; temp = num[i+12] + ama * 1000000000; num[i+12]= temp >> 32; ama = temp & 0xFFFFFFFF; temp = num[i+13] + ama * 1000000000; num[i+13]= temp >> 32; ama = temp & 0xFFFFFFFF; temp = num[i+14] + ama * 1000000000; num[i+14]= temp >> 32; ama = temp & 0xFFFFFFFF; temp = num[i+15] + ama * 1000000000; num[i+15]= temp >> 32; ama = temp & 0xFFFFFFFF; } for( ;i < len;i++){ temp = num[i] + ama * 1000000000; num[i] = temp >> 32; ama = temp & 0xFFFFFFFF; } ans += popcount(ama); //if( num[start] == 0 ){++start;} start += (num[start] == 0); start += (num[start] == 0); start += (num[start] == 0); start += (num[start] == 0); } cout << ans << endl; } }; //string str(1000000,'0'); char str[1000002]; vnum Num; void solve(){ //str.reserve(1000000); reader(str); //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; }