日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Codeforces Round #395 (Div. 2) - A

發布時間:2025/7/14 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Codeforces Round #395 (Div. 2) - A 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?

?

題目鏈接:http://codeforces.com/contest/764/problem/A

題意:有兩個人,第一個人每n分鐘到達一次目的地,第二個人每m分鐘到達一次目的地,現在給定一個時間z問在z這個時間范圍內兩人相遇的次數。

思路:由于z,n,m的范圍比較小。所以直接開個數組暴力模擬就好了。 ?更簡單的其實答案就是z/lcm(n,m)

#define _CRT_SECURE_NO_DEPRECATE #include<iostream> #include<cstring> #include<string> #include<algorithm> #include<stdio.h> #include<queue> #include<vector> #include<stack> #include<map> #include<set> #include<time.h> #include<cmath> using namespace std; #define x first #define y second #define pb push_back #define mp make_pair typedef long long int LL; const int inf = 0x3f3f3f3f; const LL INF = 0x3f3f3f3f3f3f3f3fLL; const int MAXN = 1e4 + 10; int v[MAXN]; int main(){ //#ifdef kirito // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); //#endif // int start = clock();int n,m,z;while (~scanf("%d%d%d", &n,&m,&z)){memset(v, 0, sizeof(v));for (int i = 1; i*n <= z; i++){v[i*n]++;}int ans = 0;for (int i = 1; i*m <= z; i++){if (v[i*m] > 0){ans++;}}printf("%d\n", ans);} //#ifdef LOCAL_TIME // cout << "[Finished in " << clock() - start << " ms]" << endl; //#endifreturn 0; }

?

#define _CRT_SECURE_NO_DEPRECATE #include<iostream> #include<cstring> #include<string> #include<algorithm> #include<stdio.h> #include<queue> #include<vector> #include<stack> #include<map> #include<set> #include<time.h> #include<cmath> using namespace std; #define x first #define y second #define pb push_back #define mp make_pair typedef long long int LL; const int inf = 0x3f3f3f3f; const LL INF = 0x3f3f3f3f3f3f3f3fLL; const int MAXN = 1e5 + 10; int gcd(int x, int y){return y==0? x : gcd(y, x%y); } int lcm(int x, int y){return x*y / gcd(x, y); } int main(){ //#ifdef kirito // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); //#endif // int start = clock();int n,m,z;while (~scanf("%d%d%d", &n,&m,&z)){printf("%d\n", z / lcm(n, m));} //#ifdef LOCAL_TIME // cout << "[Finished in " << clock() - start << " ms]" << endl; //#endifreturn 0; }

?

轉載于:https://www.cnblogs.com/kirito520/p/6363481.html

《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀

總結

以上是生活随笔為你收集整理的Codeforces Round #395 (Div. 2) - A的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。