QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#686353#1875. Neinuser10086Compile Error//C++231.7kb2024-10-29 11:39:452024-10-29 11:39:45

Judging History

你现在查看的是最新测评结果

  • [2024-10-29 11:39:45]
  • 评测
  • [2024-10-29 11:39:45]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 30;

#define int __int128

int f[N][N * 10];

void pre()
{
	f[0][0] = 1;
	for (int i = 0; i + 1 < N; i++) 
		for (int j = 0; j < N * 8; j++)
			if (f[i][j]) for (int k = 0; k <= 8; k++)
				assert(j + k < N * 8), f[i + 1][j + k] += f[i][j];
}

signed k, sz[N];
int pw[N];
signed x;

bool vis[N][N * 10];
int dp[N][N * 10];

int dfs(int tar, int cur, int c)
{
//	printf("dfs(%lld, %lld, %lld)\n", tar, cur, c);
	if (cur >= k) return c == tar;
	if (vis[cur][c]) return dp[cur][c];
	vis[cur][c] = true, dp[cur][c] = 0;
	for (int j = 0; j < N * 8; j++)
	{
		if (!f[sz[cur]][j] || (c + j) % 10 != tar % 10) continue;
//		printf("put %lld:\n", j);
		dp[cur][c] += f[sz[cur]][j] * dfs(tar / 10, cur + 1, (c + j) / 10);
	}
//	printf("dfs(%lld, %lld, %lld) = %lld\n", tar, cur, c, dp[cur][c]);
	return dp[cur][c];
}

signed main()
{
	cin >> k >> x; x++;
	pre();
	for (int i = 0; i <= N - 1; i++) sz[i % k]++;
	pw[0] = 1; for (int i = 1; i < N; i++) pw[i] = pw[i - 1] * 10;
	vector<int> sol;
	int cur = 0;
	for (int i = N - 1; i >= 0; i--)
	{
		for (int j = 0; ; j++)
		{
			assert(j <= 8);
			cur += j * pw[i % k], sz[i % k]--;
//			printf("i = %lld, j = %lld\n", i, j);
			int c = 0;
			for (int p = 0; p < N; p++)
			{
				int tar = p * (pw[k] - 1) - cur;
				if (tar < 0) continue;
				memset(vis, 0, sizeof vis);
				c += dfs(tar, 0, 0);
			}
//			printf("c = %lld\n", c);
			if (x <= c)
			{
				sol.push_back(j);
				break;
			}
			else x -= c, sz[i % k]++, cur -= j * pw[i % k];
		}
	}
	int tmp = 0; for (int x : sol) tmp = tmp * 10 + x;
//	cout << tmp << ' ' << (pw[k] - 1) << endl;
	cout << (int)(tmp / (pw[k] - 1));
}

Details

answer.code: In function ‘int main()’:
answer.code:77:14: error: ambiguous overload for ‘operator<<’ (operand types are ‘std::ostream’ {aka ‘std::basic_ostream<char>’} and ‘__int128’)
   77 |         cout << (int)(tmp / (pw[k] - 1));
      |         ~~~~ ^~ ~~~~~~~~~~~~~~~~~~~~~~~~
      |         |       |
      |         |       __int128
      |         std::ostream {aka std::basic_ostream<char>}
In file included from /usr/include/c++/13/bits/unique_ptr.h:42,
                 from /usr/include/c++/13/memory:78,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:56,
                 from answer.code:1:
/usr/include/c++/13/ostream:168:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’
  168 |       operator<<(long __n)
      |       ^~~~~~~~
/usr/include/c++/13/ostream:172:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’
  172 |       operator<<(unsigned long __n)
      |       ^~~~~~~~
/usr/include/c++/13/ostream:176:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’
  176 |       operator<<(bool __n)
      |       ^~~~~~~~
In file included from /usr/include/c++/13/ostream:880:
/usr/include/c++/13/bits/ostream.tcc:96:5: note: candidate: ‘std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]’
   96 |     basic_ostream<_CharT, _Traits>::
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/ostream:183:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’
  183 |       operator<<(unsigned short __n)
      |       ^~~~~~~~
/usr/include/c++/13/bits/ostream.tcc:110:5: note: candidate: ‘std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]’
  110 |     basic_ostream<_CharT, _Traits>::
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/ostream:194:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’
  194 |       operator<<(unsigned int __n)
      |       ^~~~~~~~
/usr/include/c++/13/ostream:203:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’
  203 |       operator<<(long long __n)
      |       ^~~~~~~~
/usr/include/c++/13/ostream:207:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’
  207 |       operator<<(unsigned long long __n)
      |       ^~~~~~~~
/usr/include/c++/13/ostream:222:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’
  222 |       operator<<(double __f)
      |       ^~~~~~~~
/usr/include/c++/13/ostream:226:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’
  226 |       operator<<(float __f)
      |       ^~~~~~~~
/usr/include/c++/13/ostream:234:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’
  234 |       operator<<(long double __f)
      |       ^~~~~~~~
/usr/include/c++/13/ostream:241:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(_Float16) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’
  241 |       operator<<(_Float16 __f)
      |       ^~~~~~~~
/usr/include/c++/13/ostream:250:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>...