結果
問題 |
No.2865 Base 10 Subsets 2
|
ユーザー |
![]() |
提出日時 | 2024-09-03 17:04:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 779 bytes |
コンパイル時間 | 400 ms |
コンパイル使用メモリ | 41,216 KB |
最終ジャッジ日時 | 2025-02-24 03:47:08 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:30:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 30 | scanf("%lld%lld", &n, &k); | ~~~~~^~~~~~~~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*- * * 2865.cc: No.2865 Base 10 Subsets 2 - yukicoder */ #include<cstdio> #include<algorithm> using namespace std; /* constant */ const int MAX_M = 20; /* typedef */ using ll = long long; /* global variables */ int as[MAX_M], bs[MAX_M]; ll ts[MAX_M]; /* subroutines */ /* main */ int main() { ll n, k; scanf("%lld%lld", &n, &k); k--; int m = 0; while (n > 0) as[m++] = n % 10, n /= 10; ts[0] = 1; for (int i = 1; i < m; i++) ts[i] = ts[i - 1] * (as[i - 1] + 1); for (int i = m - 1; i >= 0; i--) { bs[i] = k / ts[i]; k -= ts[i] * bs[i]; } while (m > 0 && bs[m - 1] == 0) m--; if (m == 0) puts("0"); else { for (int i = m - 1; i >= 0; i--) printf("%d", bs[i]); putchar('\n'); } return 0; }