HDU 7004 有一点数论的知识,主要体现在负数取模。
// Problem: 签到
// Contest: HDOJ
// URL: http://acm.hdu.edu.cn/showproblem.php?pid=7004
// Memory Limit: 32 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
long long mypow(long long n)
{
long long ans = 1, a = 2;
while (n)
{
if (n % 2)
ans = a * ans % mod;
a = a * a % mod;
n /= 2;
}
return ans;
}
int main()
{
int t;
scanf("%d", &t);
while (t--)
{
long long a, b, k;
scanf("%lld %lld %lld", &a, &b, &k);
long long ans1 = ((mypow(k / 2) % mod) * a % mod) % mod;
long long ans2 = ((mypow(k / 2) % mod) * b % mod) % mod;
if (k % 2 == 0)
{
printf("%lld %lld\n", ans1, ans2);
}
else
{
long long s1 = (ans1 % mod + ans2 % mod + mod) % mod;
long long s2 = ((ans1 - ans2) % mod + mod) % mod;
printf("%lld %lld\n", s1, s2);
}
// printf("%lld %lld\n", a, b);
}
}
HDU 6999 若a%c=b%c 则a%c=b%c=(a-b)%c
// Problem: 萌新
// Contest: HDOJ
// URL: http://acm.hdu.edu.cn/showproblem.php?pid=6999
// Memory Limit: 32 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int gcd(int a, int b)
{
while (b)
{
int temp = a;
a = b;
b = temp % b;
}
return a;
}
int main()
{
int t;
cin >> t;
while (t--)
{
ll a;
ll b;
cin >> a >> b;
ll c = abs(a - b);
if (c == 0)
{
if (a <= 1 || b <= 1)
{
printf("-1 -1\n");
}
else
printf("2 %lld\n", a);
}
else if (c == 1)
{
printf("-1 -1\n");
}
else
{
int temp;
int flag = 1;
for (int i = 2; i <= sqrt(c); i++)
{
if (c % i == 0)
{
flag = 0;
temp = i;
break;
}
}
if (flag == 0)
printf("%lld %lld\n", temp, c);
else
printf("%lld %lld\n", c, c);
}
}
}