码迷,mamicode.com
首页 > 其他好文 > 详细

2018 Multi-University Training Contest 1

时间:2019-09-19 19:13:21      阅读:82      评论:0      收藏:0      [点我收藏+]

标签:bre   stream   training   test   scanf   efi   tchar   const   打表   

A打表找规律

//输入一个n,找到3个数x,y,z使得x+y+z=n,可以整除n,以及xyz最大,且输出xyz
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define INF 0x3f3f3f3f
using namespace std;
const int maxn=1e6+5;
int maxx=-1;
void solve(int n){
    for(int x=1;x<=n;x++){
        for(int y=1;y<=n;y++){
            int z=n-x-y;
            if(z<=0)break;
            if(n%x==0&&n%y==0&&n%z==0){
                int zz=x*y*z;
                maxx=max(maxx,zz);
            }
        }
    }
    printf("%4d ",maxx);
    if(n%10==0)putchar('\n');
}
int main(){
    // int t;
    // scanf("%d",&t);
    // while(t--){
        int n;
        scanf("%d",&n);
        int flag=1;
        for(int i=1;i<=n;i++){
            maxx=-1;
            solve(i);
        }
    // }
    return 0;
}
/*
20
  -1   -1    1    2   -1    8   -1   16   27   -1
  -1   64   -1   -1  125  128   -1  216   -1  250
3的倍数
3  1
6  8
9  27
12 64
15 125
18 216


4的倍数
4  2
8  16
12 64
16 128
20 250
*/

2018 Multi-University Training Contest 1

标签:bre   stream   training   test   scanf   efi   tchar   const   打表   

原文地址:https://www.cnblogs.com/Emcikem/p/11551757.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!