• 1047A_Little C Loves 3 I(构造)


    A. Little C Loves 3 I
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    Little C loves number «3» very much. He loves all things about it.

    Now he has a positive integer nn. He wants to split nn into 33 positive integers a,b,ca,b,c, such that a+b+c=na+b+c=n and none of the 33 integers is a multiple of 33. Help him to find a solution.

    Input

    A single line containing one integer nn (3n1093≤n≤109) — the integer Little C has.

    Output

    Print 33 positive integers a,b,ca,b,c in a single line, such that a+b+c=na+b+c=n and none of them is a multiple of 33.

    It can be proved that there is at least one solution. If there are multiple solutions, print any of them.

    Examples
    input
    Copy
    3
    output
    Copy
    1 1 1
    input
    Copy
    233
    output
    Copy
    77 77 79
    被样例困惑了很久,看了题解啧啧,其实这题就是构造
    大致题意:给你一个数n,找到三个数a,b,c,使得a+b+c=n,并且a,b,c都不能是3的倍数
    分析:当n%3=0时,n-2一定不是3的倍数,可以构造为a=1,b=1,c=n-2;当n%3!=0时,n-3一定不是3的倍数,那么可以构造为,a=1,b=2,c=n-3.注意这个构造是任意的,只要满足条件即可
     1 #include<cstdio>
     2 #include<cstring>
     3 #include<algorithm>
     4 using namespace std;
     5 int main()
     6 {
     7     int n;
     8     while(~scanf("%d",&n))
     9     {
    10         if(n%3==0)
    11             printf("1 1 %d
    ",n-2);
    12         else
    13             printf("1 2 %d
    ",n-3);
    14     }
    15     return 0;
    16 }


  • 相关阅读:
    js动态给对象添加事件
    JavaScript中提供获取HTML元素位置的属性:
    javascript:是什么意思
    Vector与ArrayList区别
    Java核心类库——集合的迭代(遍历) Iterator接口
    实例1(文字的放大缩小)
    基本控件的使用
    关于Android那些事
    初识Android
    JavaScript(Two)
  • 原文地址:https://www.cnblogs.com/LLLAIH/p/9736335.html
Copyright © 2020-2023  润新知