Rearrangement

Description
In a two dimensional array of integers of size 2 \times n2×n, is it possible to rearrange integers so that the sum of two adjacent elements (which are adjacent in a common row or a common column) is never divisible by three?

Input
The input has several test cases and the first line contains an integer t (1 \le t \le 200)t(1≤t≤200) which is the number of test cases.

In each case, the first line contains an integers n (1 \le n \le 10000)n(1≤n≤10000) indicating the number of columns in the array. The second line contains the elements of the array in the first row separated by single spaces. The third line contains the elements of the array in the second row separated by single spaces. The elements will be positive integers less then 10000001000000.

Output
For each test case, output “YES” in a single line if any valid rearrangement exists, or “NO” if not.

样例输入
6
3
3 6 9
1 4 7
3
3 6 9
1 3 8
5
1 2 3 4 5
6 7 8 9 10
10
1 1 1 1 1 1 1 1 1 1
2 3 2 3 2 3 2 3 2 3
2
3 1
2 3
2
3 1
1 2
样例输出
YES
NO
YES
YES
YES
NO
题目大意
给定一个2*n的规格的两行数字,问是否可以重新排列,使其任意两个相邻数字之和不能被3整除。
思路
这是一道思维题,首先要明白不能让两数之和被3整除,那么不难想到这两个数字必须满足以下条件:两数分别对3取余之和不能为3,即不能是1和2;两数对3取余不能同时为0。也就是说只有当两数对3取余为1和1,2和2,0和1,或者0、2时满足条件。
由此我们可以得到不能使对3取余为0、0或者1、2的两数相邻。
可以得到以下情况时为符合条件的情况(方便起见以下0、1、2代表对3取余为0、1、2的数字):

…1 1 1 0 2 2 2 …
…1 1 1 1 0 1 1 …
也就是:2与1不相互接触,用0分隔开,且0只有两个。

只有0、1或者0、2,且0的数目小于n(即一行)。

只剩下1或2

#include <stdio.h>
int main()
{
    int t;
    int mod0=0,mod1=0,mod2=0;
    scanf("%d",&t);
    while(t--)
    {
        int n;
        int i;
        mod0=0;mod1=0;mod2=0;
        scanf("%d",&n);
        for(i=0;i<2*n;i++)
        {
            int x;
            scanf("%d",&x);
            if(x%3==0)
                mod0++;
            else if(x%3==1)
                mod1++;
            else
                mod2++;
        }
        if(mod0>n || (mod0<=1 && mod1 && mod2))// 0数目大于n 以及 排除只剩下剩下1和2的情况
            printf("NO\n");
        else if(mod1==0 || mod2==0)// 只剩下0、1或者0、2的情况
            printf("YES\n");
        else if(mod0==2 && mod1%2==0 && mod2%2==0)// 2与1不相互接触,用0分隔开,且0只有两个的情况
            printf("NO\n");
        else
            printf("YES\n");
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
润色下面英文:The controlled drug delivery systems, due to their precise control of drug release in spatiotemporal level triggered by specific stimulating factors and advantages such as higher utilization ratio of drug, less side-effects to normal tissues and so forth, provide a new strategy for the precise treatment of many serious diseases, especially tumors. The materials that constitute the controlled drug delivery systems are called “smart materials” and they can respond to the stimuli of some internal (pH, redox, enzymes, etc.) or external (temperature, electrical/magnetic, ultrasonic and optical, etc.) environments. Before and after the response to the specific stimulus, the composition or conformational of smart materials will be changed, damaging the original balance of the delivery systems and releasing the drug from the delivery systems. Amongst them, the photo-controlled drug delivery systems, which display drug release controlled by light, demonstrated extensive potential applications, and received wide attention from researchers. In recent years, photo-controlled drug delivery systems based on different photo-responsive groups have been designed and developed for precise photo-controlled release of drugs. Herein, in this review, we introduced four photo-responsive groups including photocleavage groups, photoisomerization groups, photo-induced rearrangement groups and photocrosslinking groups, and their different photo-responsive mechanisms. Firstly, the photocleavage groups represented by O-nitrobenzyl are able to absorb the energy of the photons, inducing the cleavage of some specific covalent bonds. Secondly, azobenzenes, as a kind of photoisomerization groups, are able to convert reversibly between the apolar trans form and the polar cis form upon different light irradiation. Thirdly, 2-diazo-1,2-naphthoquinone as the representative of the photo-induced rearrangement groups will absorb specific photon energy, carrying out Wolff rearrangement reaction. Finally, coumarin is a promising category photocrosslinking groups that can undergo [2+2] cycloaddition reactions under light irradiation. The research progress of photo-controlled drug delivery systems based on different photo-responsive mechanisms were mainly reviewed. Additionally, the existing problems and the future research perspectives of photo-controlled drug delivery systems were proposed.
02-06

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值