結果
| 問題 |
No.2562 数字探しゲーム(緑以下コンver.)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-12-02 16:56:22 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,555 bytes |
| コンパイル時間 | 775 ms |
| コンパイル使用メモリ | 76,680 KB |
| 最終ジャッジ日時 | 2025-02-18 05:47:19 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 3 TLE * 1 -- * 6 |
ソースコード
/**
* @file 2562.cpp
* @brief yukicoder No.2562 数字探しゲーム(緑以下コンver.)
* @author Keitaro Naruse
* @date 2023-12-02
* @copyright MIT License
* @details https://yukicoder.me/problems/no/2562
* */
// # Solution
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
template < class T >
std::ostream& operator<<( std::ostream& os, const std::vector< T >& v ) {
for( auto it = v.begin( ); it != v.end( ); it++ ) {
os << *it << ( it == --v.end( ) ? "" : " " );
}
return os;
}
int main( ) {
// Read T = [ 1, 10^4 ]
int T;
std::cin >> T;
// Multiple queries
for( int t = 0; t < T; t++ ) {
// Read M = [ 1, 10^9 ]
long long M;
std::cin >> M;
// Read di = [ 1, 9 ]
std::vector< int > d( 10 );
for( int i = 1; i <= 9; i++ ) {
std::cin >> d.at( i );
}
// Main::Preprocess
std::string digits;
for( int i = 1; i <= 9; i++ ) {
for( char j = 0; j < d.at( i ); j++ ) {
digits.push_back( '0' + i );
}
}
long long answer = 0LL;
do {
long long val = std::stoll( digits );
if( val % M == 0LL ) {
answer = val;
break;
}
} while( std::next_permutation( digits.begin( ), digits.end( ) ) );
// Main::Find a solution
// Main::Output a solution
std::cout << answer << std::endl;
}
// Finalize
return 0;
}