A. Alternative Architecture

                                                        A. Alternative Architecture

Problem - A - Codeforces

 

 

思路:首先输入a,b,首先将a--,b--,这样就转化为了,将四个顶点方到四个格点上的不同的方案数,但是还不确定为什么这样,然后我们可以得到一个方程x^2+y^2=a^2,然后我们枚举x==[1~a-1],然后解出另一个点的坐标,得到b* y/a,b*x/a,只要这两个是整数,则是一种合法的方案,同时一定存在一种方案是平行x轴y轴放,所以res初值为1,然后再求出来之后,需要根据a与b是否相等判断是否乘2,因为如果a,b不相等,则乘2,因为他可以先通过计算x^2+y^2=b^2,得到另一组解

// Problem: A. Alternative Architecture
// Contest: Codeforces - 2022-2023 ACM-ICPC German Collegiate Programming Contest (GCPC 2022)
// URL: https://codeforces.com/gym/104059/problem/A
// Memory Limit: 512 MB
// Time Limit: 1000 ms

#include<iostream>
#include<cstring>
#include<string>
#include<sstream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<vector> 
#include<set>
#include<unordered_map>
#include<ctime>
#include<cstdlib>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> PII;
typedef pair<int,pair<int,int> > PIII;
const double eps=1e-7;
const int N=5e5+7 ,M=5e5+7, INF=0x3f3f3f3f,mod=1e9+7;
const long long int llINF=0x3f3f3f3f3f3f3f3f;
inline ll read() {ll x=0,f=1;char c=getchar();while(c<'0'||c>'9') {if(c=='-') f=-1;c=getchar();}
while(c>='0'&&c<='9') {x=(ll)x*10+c-'0';c=getchar();} return x*f;}
inline void write(ll x) {if(x < 0) {putchar('-'); x = -x;}if(x >= 10) write(x / 10);putchar(x % 10 + '0');}
inline void write(ll x,char ch) {write(x);putchar(ch);}
void stin() {freopen("in_put.txt","r",stdin);freopen("my_out_put.txt","w",stdout);}
bool cmp0(int a,int b) {return a>b;}
template<typename T> T gcd(T a,T b) {return b==0?a:gcd(b,a%b);}
template<typename T> T lcm(T a,T b) {return a*b/gcd(a,b);}
void hack() {printf("\n----------------------------------\n");}

int T,hackT;
int n,m,k;

void solve() {
	int a=read(),b=read();
	a--,b--;
	if(a>b) swap(a,b);
	int res=1;
	for(int i=1;i<=a-1;i++) {
		ll s=(ll)a*a-(ll)i*i;
		ll temp=sqrt(s);
		if((ll)temp*temp==s) {
			if(((ll)b*i)%a==0&&((ll)b*temp)%a==0) {
				res++;
			}
		}
	}
	if(a!=b) res=res*2;
	
	printf("%d\n",res);
}   

int main() {
    // init();
    // stin();

    // scanf("%d",&T);
    T=1; 
    while(T--) hackT++,solve();
    
    return 0;       
}          

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值