Given a set A of N unordered 128-bit numbers. You are to compute a value of the function
where A
k — the k
th element of A, log
10X — the integer part of the decimal logarithm of X. We’ll assume that log
100 = 0.
Input
The first input line contains a number N <= 5000. In the following N lines there are 128-bit numbers A
k presented by sets of numbers (a
1k, a
2k, a
3k, a
4k), each of them lies in range from 0 to 2
32-1. The number A
k can be obtained from this set according to the formula
A
k = 2
96a
1k + 2
64a
2k + 2
32a
3k + a
4k.
Output
You are to output the value of the function for the given set.
Sample
input
output
2 0 0 0 2324 0 2332 0 0
44
Problem Author: Idea: Nikita Shamgunov, prepared by Nikita Shamgunov, Anton Botov
Problem Source: VIII Collegiate Students Urals Programming Contest. Yekaterinburg, March 11-16, 2004
解答如下(只保留 Main 方法):
staticvoid Main() { UInt128[] numbers = UInt128.Read(Console.In); int v =0; for (int i =0; i < numbers.Length -1; i++) for (int j = i +1; j < numbers.Length; j++) v += UInt128.Log10(UInt128.Xor(numbers[i], numbers[j])); Console.WriteLine(v *2); }
1using System; 2using System.IO; 3 4namespace Skyiv.Ben.Timus 5{ 6//http://acm.timus.ru/problem.aspx?space=1&num=1318 7sealedclass T1318b 8 { 9staticreadonlyint nUInt =128/32; 10 11staticvoid Main() 12 { 13 var p = Read(Console.In); 14 Console.WriteLine(2* Solve(p)); 15 } 16 17staticuint[] Read(TextReader reader) 18 { 19 var n =int.Parse(reader.ReadLine()); 20 var p =newuint[n * nUInt]; 21for (var i =0; i < n; i++) 22 { 23 var ss = reader.ReadLine().Split(); 24for (var j =0; j < nUInt; j++) p[i * nUInt + j] =uint.Parse(ss[j]); 25 } 26return p; 27 } 28 29staticint Solve(uint[] p) 30 { 31 var v =0; 32for (var i = p.Length / nUInt -1; i >0; i--) 33for (var j = i -1; j >=0; j--) 34 { 35 var u = i * nUInt; 36 var y = j * nUInt; 37 var a = p[u] ^ p[y]; 38 var b = p[u +1] ^ p[y +1]; 39 var c = p[u +2] ^ p[y +2]; 40 var d = p[u +3] ^ p[y +3]; 41if (a ==0&& b ==0&& c ==0) goto label1; 42if (a >1262177448|| a ==1262177448&& (b >1518781562|| b ==1518781562&& c >=160047680)) { v +=38; continue; } 43if (a >126217744|| a ==126217744&& (b >3587851993|| b ==3587851993&& c >=16004768)) { v +=37; continue; } 44if (a >12621774|| a ==12621774&& (b >2076772117|| b ==2076772117&& c >=3008077584)) { v +=36; continue; } 45if (a >1262177|| a ==1262177&& (b >1925664130|| b ==1925664130&& c >=730304488)) { v +=35; continue; } 46if (a >126217|| a ==126217&& (b >3199043520|| b ==3199043520&& c >=932023908)) { v +=34; continue; } 47if (a >12621|| a ==12621&& (b >3326381459|| b ==3326381459&& c >=952195850)) { v +=33; continue; } 48if (a >1262|| a ==1262&& (b >762134875|| b ==762134875&& c >=2242703233)) { v +=32; continue; } 49if (a >126|| a ==126&& (b >935206946|| b ==935206946&& (c >3230747430|| c ==3230747430&& d >2147483647))) { v +=31; continue; } 50if (a >12|| a ==12&& (b >2670501072|| b ==2670501072&& (c >1182068202|| c ==1182068202&& d >1073741823))) { v +=30; continue; } 51if (a >1|| a ==1&& (b >1126043566|| b ==1126043566&& (c >1836193738|| c ==1836193738&& d >2684354559))) { v +=29; continue; } 52if (a >0|| b >542101086|| b ==542101086&& (c >1042612833|| c ==1042612833&& d >268435455)) { v +=28; continue; } 53if (b >54210108|| b ==54210108&& (c >2681241660|| c ==2681241660&& d >3892314111)) { v +=27; continue; } 54if (b >5421010|| b ==5421010&& (c >3704098002|| c ==3704098002&& d >3825205247)) { v +=26; continue; } 55if (b >542101|| b ==542101&& (c >370409800|| c ==370409800&& d >1241513983)) { v +=25; continue; } 56if (b >54210|| b ==54210&& (c >466537709|| c ==466537709&& d >2701131775)) { v +=24; continue; } 57if (b >5421|| b ==5421&& (c >46653770|| c ==46653770&& d >4135583743)) { v +=23; continue; } 58if (b >542|| b ==542&& (c >434162106|| c ==434162106&& d >2990538751)) { v +=22; continue; } 59if (b >54|| b ==54&& (c >902409669|| c ==902409669&& d >3735027711)) { v +=21; continue; } 60if (b >5|| b ==5&& (c >1808227885|| c ==1808227885&& d >1661992959)) { v +=20; continue; } 61if (b >0|| c >2328306436|| c ==2328306436&& d >2328306435) { v +=19; continue; } 62if (c >232830643|| c ==232830643&& d >2808348671) { v +=18; continue; } 63if (c >23283064|| c ==23283064&& d >1569325055) { v +=17; continue; } 64if (c >2328306|| c ==2328306&& d >1874919423) { v +=16; continue; } 65if (c >232830|| c ==232830&& d >2764472319) { v +=15; continue; } 66if (c >23283|| c ==23283&& d >276447231) { v +=14; continue; } 67if (c >2328|| c ==2328&& d >1316134911) { v +=13; continue; } 68if (c >232|| c ==232&& d >3567587327) { v +=12; continue; } 69if (c >23|| c ==23&& d >1215752191) { v +=11; continue; } 70if (c >2|| c ==2&& d >1410065407) { v +=10; continue; } 71 label1: 72if (c >0|| d >999999999) { v +=9; continue; } 73if (d >99999999) { v +=8; continue; } 74if (d >9999999) { v +=7; continue; } 75if (d >999999) { v +=6; continue; } 76if (d >99999) { v +=5; continue; } 77if (d >9999) { v +=4; continue; } 78if (d >999) { v +=3; continue; } 79if (d >99) { v +=2; continue; } 80if (d >9) { v ++; continue; } 81 } 82return v; 83 } 84 } 85}
1. If语句作为表达式
val properties = if (jobIdToActiveJob.contains(jobId)) {
jobIdToActiveJob(stage.jobId).properties
} else {
// this stage will be assigned to "default" po
基础测试题
卷面上不能出现任何的涂写文字,所有的答案要求写在答题纸上,考卷不得带走。
选择题
1、 What will happen when you attempt to compile and run the following code? (3)
public class Static {
static {
int x = 5; // 在static内有效
}
st
表里的一行对于一个数据块太大的情况有二种(一行在一个数据块里放不下)
第一种情况:
INSERT的时候,INSERT时候行的大小就超一个块的大小。Oracle把这行的数据存储在一连串的数据块里(Oracle Stores the data for the row in a chain of data blocks),这种情况称为行链接(Row Chain),一般不可避免(除非使用更大的数据
Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?
For example,Given sorted array nums = [1,1,1,2,2,3],
Your function should return length