Submission #20397619


Source Code Expand

Copy
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long int
#define fast ios_base::sync_with_stdio(false)
#define fast_input cin.tie(NULL)
#define fast_output cout.tie(NULL)
#define vi vector<long long int>
#define vii vector<vi>
#define vc vector<char>
#define vcc vector<vc>
#define vp vector<pair<ll, ll>>
#define vpp vector<pair<ll, pair<ll, ll>>>
#define pb push_back
#define pu push
#define po pop
#define up(v, x) upper_bound(v.begin(), v.end(), x)
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll long long int
#define fast ios_base::sync_with_stdio(false)
#define fast_input cin.tie(NULL)
#define fast_output cout.tie(NULL)
#define vi vector<long long int>
#define vii vector<vi>
#define vc vector<char>
#define vcc vector<vc>
#define vp vector<pair<ll, ll>>
#define vpp vector<pair<ll, pair<ll, ll>>>
#define pb push_back
#define pu push
#define po pop
#define up(v, x) upper_bound(v.begin(), v.end(), x)
#define lo(v, x) lower_bound(v.begin(), v.end(), x)
#define ups(v, x) v.upper_bound(x)
#define los(v, x) v.loer_bound(x)
#define pa pair<long long int, long long int>
#define f(a, x, b) for (int a = x; a < b; a++)
#define fr(a, x, b) for (int a = x; a >= b; a--)
#define EACH(a, x) for (auto a : x)
#define sort(x) sort(x.begin(), x.end())
#define rev(x) reverse(x.begin(), x.end())
#define sz(a) (int)a.size()
#define mod 1000000007
#define F first
#define S second
#define endl "\n"
#define um unordered_map<ll, ll>
#define ordered_set tree < pa, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update

vector<string> vec_splitter(string s)
{
	s += ',';
	vector<string> res;
	while (!s.empty())
	{
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
	vector<string> __attribute__((unused)) args,
	__attribute__((unused)) int idx,
	__attribute__((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T)
{
	if (idx > 0)
		cerr << ", ";
	else
		cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss;
	ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
ll powmod(ll a, ll b, ll modo = 10)
{
	ll res = 1;
	while (b)
	{
		if (b % 2)
		{
			res = res * a;
		}
		a = a * a;
		b /= 2;
		a %= modo;
		res %= modo;
	}
	return res;
}
void solve()
{
	ll a, b, c;
	cin >> a >> b >> c;
	ll has[10][10];
	f(i, 0, 10)
	{
		ll go = i;
		has[i][1] = i;
		ll co = 2;
		do
		{
			go = go * i;
			has[i][co] = go % 10;
			co++;
		} while (co < 10);
	}
	if (a % 10 == 1 || a % 10 == 5 || a % 10 == 0 || a % 10 == 6)
	{
		cout << a % 10 << endl;
	}
	else
	{
		ll modo=4;
		if(a%10==4||a%10==9)
		{
			modo=2;
		}
		ll go=(powmod(b%modo,c,1000));
		go%=modo;
		if(go==0)
		{
			go=4;
			if(a%10==4||a%10==9)
			{
				go=2;
			}
		}
		cout<<has[a%10][go]<<endl;
	}
}
int main()
{
	fast;
	fast_input;
	fast_output;
	// ll t;
	// cin >> t;
	// f(i, 0, t)
	// {
	//  cout<<"Case #"<<i+1<<":"<<" ";
	solve();
	// }
	return 0;
}

Submission Info

Submission Time
Task B - A^B^C
User swalen
Language C++ (GCC 9.2.1)
Score 400
Code Size 2994 Byte
Status AC
Exec Time 8 ms
Memory 3616 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 28
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt AC 8 ms 3512 KB
02.txt AC 3 ms 3604 KB
03.txt AC 2 ms 3616 KB
04.txt AC 2 ms 3480 KB
05.txt AC 2 ms 3448 KB
06.txt AC 2 ms 3468 KB
07.txt AC 3 ms 3448 KB
08.txt AC 3 ms 3564 KB
09.txt AC 2 ms 3608 KB
10.txt AC 2 ms 3524 KB
11.txt AC 4 ms 3448 KB
12.txt AC 2 ms 3616 KB
13.txt AC 4 ms 3560 KB
14.txt AC 2 ms 3564 KB
15.txt AC 2 ms 3564 KB
16.txt AC 2 ms 3520 KB
17.txt AC 2 ms 3452 KB
18.txt AC 2 ms 3508 KB
19.txt AC 2 ms 3448 KB
20.txt AC 2 ms 3564 KB
21.txt AC 2 ms 3444 KB
22.txt AC 2 ms 3520 KB
23.txt AC 2 ms 3512 KB
24.txt AC 2 ms 3516 KB
25.txt AC 2 ms 3508 KB
s1.txt AC 2 ms 3528 KB
s2.txt AC 3 ms 3516 KB
s3.txt AC 2 ms 3448 KB


2025-03-29 (Sat)
11:46:07 +00:00