蓝桥杯c-c++省赛试题及答案解析 联系客服

发布时间 : 星期二 文章蓝桥杯c-c++省赛试题及答案解析更新完毕开始阅读

3

1250 200 32

程序应该输出: 25/4

再例如,输入: 4

3125 32 32 200

程序应该输出: 5/2

再例如,输入: 3

549755813888 524288 2

程序应该输出: 4/1

资源约定:

峰值内存消耗 < 256M CPU消耗 < 3000ms

请严格按要求输出,不要画蛇添足地打印类似:“请您输入...”编辑版word

的多余内容。

所有代码放在同一个源文件中,调试通过后,拷贝提交该源码。

注意: main函数需要返回0

注意: 只使用ANSI C/ANSI C++ 标准,不要调用依赖于编译环境或操作系统的特殊函数。 注意: 所有依赖的函数必须明确地在源文件中 #include ,常用头文件。

提交时,注意选择所期望的编译器类型。 答案:

#include #include #include using namespace std; #define LL long long struct fs {

LL up,down; }; int n; LL arr[110]; fs Fs[110];

bool cmp(LL a,LL b)

编辑版word

不能通过工程设置而省略 {

return a > b; }

LL Gcd(LL a,LL b) {

if( b == 0 )return a; return Gcd(b,a%b); }

LL Get(LL a, LL b) {

if( a < b) a ^= b ^= a ^= b; LL v[30]; queueteam;

if( a == b || a / b == a) return b; v[0] = a, v[1] = b; v[2] = a / b; int top = 3,i,j; team.push(a/b); while(team.size()) {

LL now = team.front(); team.pop();

for(i = 0 ; i < top ; i ++) {

编辑版word

LL temp = (v[i] > now) ? v[i] / now : now / v[i]; bool find = false; for(j = 0 ; j < top ; j ++) if( v[j] == temp) find = true; if(find == true) continue; team.push(temp); v[top++] = temp; } }

LL ans = v[0];

for(i = 0 ; i < top ; i ++) if(v[i] != 1) {

ans = v[i]; break; }

for(i = 0 ; i < top ; i ++)

if( v[i] < ans && v[i] != 1) ans = v[i]; return ans; } int main() { int i,j;

scanf(\

for(i = 0 ; i < n ; i ++) scanf(\

编辑版word