Light OJ 1001

1001

This problem gives you a flavor the concept of specialjudge. That means the judge is smart enough to verify your code even though itmay print different results. In this problem you are asked to find the oppositetask of the previous problem.

To be specific, I have two computers where I stored myproblems. Now I know the total number of problems isn. And there are noduplicate problems and there can be at most 10 problems in each computer.You have to find the number of problems in each of the computers.

Since there can be multiple solutions. Any valid solutionwill do.

Input

Input starts with an integer T (≤ 25),denoting the number of test cases.

Each case starts with a line containing an integer n (0≤ n ≤ 20) denoting the total number of problems.

Output

For each case, print the number of problems stored in eachcomputer in a single line. A single space should separate the non-negative integers.

这道题目好多的误解啊,这样就难做了,问同济的同学算是解了出来。。。。




#include<stdio.h>
int main()
{
    int n[50],m[50],i,num,k;
    scanf("%d",&num);
    for(i=0;i<num;i++)
    {    scanf("%d",&n[i]);
    if(n[i]>20) return 0;
        m[i]=0;
        while(n[i]-m[i]>10)
        {m[i]++;
        
        }
    for(k=i-1;k>=0;k--)
    {    if(n[i]==n[k]){m[i]=m[k]+1;break;}
    
    
    }
    if(m[i]>10) return 0;
    printf("%d %d\n",m[i],n[i]-m[i]);
    
    
    }
    return 0;

}

不想没这么复杂。。。。

修改:

 #include<stdio.h>
    int main()
    {
        int n[50],m[50],i,num;
        scanf("%d",&num);
        for(i=0;i<num;i++)
        {   scanf("%d",&n[i]);
        if(n[i]>20) return 0;
            m[i]=0;
            while(n[i]-m[i]>10)
            {m[i]++;
           
            }
       
        if(m[i]>10) return 0;
        printf("%d %d\n",m[i],n[i]-m[i]);
       
       
        }
        return 0;
     
    }

AC了


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值