ShoutterDiv2

/*
Problem Statement for ShoutterDiv2


Problem Statement
    	
A group of freshman rabbits has recently joined the Eel club. No two of the rabbits knew each other. Today, each of the rabbits went to the club for the first time. You are given int[]s s and t with the following meaning: For each i, rabbit number i entered the club at the time s[i] and left the club at the time t[i].

Each pair of rabbits that was in the club at the same time got to know each other, and they became friends on the social network service Shoutter. This is also the case for rabbits who just met for a single moment (i.e., one of them entered the club exactly at the time when the other one was leaving).

Compute and return the number of pairs of rabbits that became friends today.

 
Definition
    	
Class:	ShoutterDiv2
Method:	count
Parameters:	int[], int[]
Returns:	int
Method signature:	int count(int[] s, int[] t)
(be sure your method is public)
    
 
Constraints
-	s and t will contain between 1 and 50 integers, inclusive.
-	s and t will contain the same number of elements.
-	Each integer in s and t will be between 0 and 100, inclusive.
-	For each i, t[i] will be greater than or equal to s[i].
 
Examples
0)	
    	
{1, 2, 4}
{3, 4, 6}
Returns: 2
Rabbit 0 and Rabbit 1 will be friends because both of them are in the club between time 2 and 3. 

Rabbit 0 and Rabbit 2 won't be friends because Rabbit 0 will leave the club before Rabbit 2 enters the club. 

Rabbit 1 and Rabbit 2 will be friends because both of them are in the club at time 4. 

1)	
    	
{0}
{100}
Returns: 0
2)	
    	
{0,0,0}
{1,1,1}
Returns: 3
3)	
    	
{9,26,8,35,3,58,91,24,10,26,22,18,15,12,15,27,15,60,76,19,12,16,37,35,25,4,22,47,65,3,2,23,26,33,7,11,34,74,67,32,15,45,20,53,60,25,74,13,44,51}
{26,62,80,80,52,83,100,71,20,73,23,32,80,37,34,55,51,86,97,89,17,81,74,94,79,85,77,97,87,8,70,46,58,70,97,35,80,76,82,80,19,56,65,62,80,49,79,28,75,78}
Returns: 830
*/

public class ShouttleDiv2 {
	public static void main(String argv[]){
		int s[]={9,26,8,35,3,58,91,24,10,26,22,18,15,12,15,27,15,60,76,19,12,16,37,35,25,4,22,47,65,3,2,23,26,33,7,11,34,74,67,32,15,45,20,53,60,25,74,13,44,51};
		
		int t[]={26,62,80,80,52,83,100,71,20,73,23,32,80,37,34,55,51,86,97,89,17,81,74,94,79,85,77,97,87,8,70,46,58,70,97,35,80,76,82,80,19,56,65,62,80,49,79,28,75,78};
		
		System.out.println(new ShouttleDiv2().count(s,t));
	}
	
	public int count(int []s,int []t){
		int counter=0;
		if(s.length<=0 || s.length !=t.length)
		{
			throw new IllegalArgumentException("");
			//return counter;
		}
		for(int i=0;i<s.length;i++)
		{
			for(int j=i+1;j<s.length;j++)
			{
				if(s[i]>t[j] || s[j]>t[i])continue;
					counter ++;
			}
		}
		
		return counter;
	}
}

算法复杂度,穷举O(N^2) 

资源下载链接为: https://pan.quark.cn/s/abbae039bf2a 在Android开发过程中,要实现对设备的自动化测试或模拟用户操作,可以通过代码模拟点击来达成。接下来就来详细说说利用ADB工具,借助shell命令的sendevent指令模拟触摸屏事件的过程及相关知识。 Android Debug Bridge(ADB):这是Android开发者常用的工具,它使开发者能够在电脑上与连接的Android设备进行交互,完成调试、日志输出、应用安装、执行shell命令等众多操作。 Shell命令:在Android设备上,可通过shell命令行来执行系统级别的各类操作,其中sendevent命令可用于模拟输入事件,像触摸屏的点击、滑动等操作都可实现。 sendevent命令详解:sendevent命令是通过向Linux内核的输入子系统发送模拟事件来工作的,其基本格式是sendevent <设备路径> <事件类型> <事件代码> <事件值>。其中,“设备路径”一般为/dev/input/event*,是设备输入事件的接口;“事件类型”有EV_SYN(同步事件)、EV_KEY(按键事件)、EV_ABS(绝对坐标事件)等常见类型;“事件代码”对应着具体的按键或触摸屏坐标等,例如对于触摸屏,会涉及ABS_X和ABS_Y;“事件值”则是事件的具体数值,像坐标位置、按键状态等。 模拟点击操作步骤:首先通过adb connect <设备IP>:<端口号>命令利用ADB连接到设备。接着使用getevent -l命令找到触摸屏的设备路径。然后构造sendevent命令来模拟点击,比如模拟在(100, 200)位置点击,命令如下: 执行这些命令就能完成一次点击操作的模拟。 5. EventInjector类:提供的名为EventInjector的压缩包文件可能是一个Java类,
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值