首页 > 小红走网格
头像 番禺小韭菜
发表于 2025-03-05 19:26:52
#include <iostream> using namespace std; int gcd(int a, int b){ return b==0? a : gcd(b, a%b); } void solve(){ int x, y, a, b, c, d; 展开全文
头像 XiaoXiauwu
发表于 2025-04-17 20:08:54
水题,题意是给定目标网格,以及向上下左右一次能移动的格子数,问不限移动次数的情况下,是否可以移动到目标位置。不难发现向y方向移动的步数仅和 gcd (a, b) 有关,x方向同理,因此直接写if判断目标位置x坐标能否被gcd(a, b)整除即可,y坐标同理。 #include<bits/std 展开全文
头像 Goldminer
发表于 2025-04-23 22:35:32
#include <iostream> // 包含输入输出流相关的头文件 #include <vector> // 包含 vector 容器相关的头文件 using namespace std; // 使用标准命名空间,避免重复写 std:: // 自定义 gcd 函 展开全文
头像 000c
发表于 2025-04-14 10:35:56
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int T 展开全文
头像 扎男_
发表于 2025-04-16 15:15:39
// // 活动地址: 牛客春招刷题训练营 - 编程打卡活动 #include <stdio.h> int main() { int n,a,b,c,d,i,j,x,y,t; scanf("%d",&n); for(i=0;i< 展开全文
头像 剑绝尘
发表于 2025-04-17 22:40:48
#include <bits/stdc++.h> using namespace std; int gcd(int x,int y){ return y ? gcd(y,x%y) : x; } int main(){ int t;cin>>t; w 展开全文
头像 牛客856751393号
发表于 2025-03-11 17:58:52
from math import gcd while True: try: T = int(input()) for _ in range(T): x, y, a, b, c, d = map(int, input().split() 展开全文
头像 叫啥名
发表于 2025-04-17 11:43:09
// #牛客春招刷题训练营# https://www.nowcoder.com/discuss/726480854079250432 #include <algorithm> #include <iostream> using namespace std; int gcd( 展开全文
头像 ZyWoOoO
发表于 2025-04-17 12:27:14
#include <bits/stdc++.h> // for gcd in C++17 using namespace std; // 如果您使用的编译器不支持 C++17 的 std::gcd,可以手动实现 gcd 函数 int gcd(int a, int b) { ret 展开全文
头像 牛客719093728号
发表于 2025-03-27 14:44:35
#include <iostream> using namespace std; int gcd(int a,int b){ if(b == 0){ return a; } return gcd(b,a % b); } int main(){ 展开全文