結果

問題 No.2865 Base 10 Subsets 2
ユーザー 沙耶花
提出日時 2024-08-30 21:28:13
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 618 bytes
コンパイル時間 4,254 ms
コンパイル使用メモリ 251,540 KB
最終ジャッジ日時 2025-02-24 02:52:22
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001

int main(){
	
	long long N,K;
	cin>>N>>K;
	K--;
	vector<long long> c;
	c.push_back(1);
	while(N!=0){
		long long cur = N%10;
		N /= 10;
		c.push_back(c.back() * (cur+1));
	}
	long long t = 1;
	long long ans = 0;
	rep(i,c.size()){
		while(K>0){
			if(i+1!=c.size() && K%c[i+1]==0)break;
			K -= c[i];
			ans += t;
		}
		t *= 10;
		
	}
	cout<<ans<<endl;
    return 0;
}
0