do hoanganh

@ei150031anh

Viet Nam, Bình duong

Institution: eiu

class giatri : IComparable<giatri> { public long batdau { get; set; } public long ketthuc { get; set; } public long newtime { get; set; } public System.Int32 CompareTo(giatri other) { if (this.batdau != other.batdau) { return this.batdau.CompareTo(other.batdau); } else if (this.batdau == other.batdau && this.ketthuc != other.ketthuc) { return this.ketthuc.CompareTo(other.ketthuc); } else if (this.batdau == other.batdau && this.ketthuc == other.ketthuc) { return this.newtime.CompareTo(other.newtime); } return -1; } //public override string ToString() //{ // //String representation. // return this.batdau.ToString() + " " + this.ketthuc+" "+this.newtime; //} } class Program { public static void Main(string[] args) { List<giatri> SORT = new List<giatri>(); StringBuilder sbxuat = new StringBuilder(); long n = NextLong(); long[] start = new long[n]; long[] end = new long[n]; long[] time = new long[n]; long[] xuat = new long[n]; // double m = NextLong(); double tong = 0; for (int i = 0; i < n; i++) { start[i] = NextInt(); end[i] = NextInt(); time[i] = end[i] - start[i]; } for (long i = 0; i < n; i++) { SORT.Add(new giatri() { batdau = start[i], ketthuc = end[i], newtime = time[i] }); } double dem = 0; SORT.Sort(); long temp = 0; for (int i = 0; i < n; i++) { xuat[i] = SORT[i].newtime; for (int j = 0; j < i - 1; j++) { if (SORT[i].batdau >= SORT[j].ketthuc && xuat[i] < xuat[j] + SORT[i].newtime) { xuat[i] = xuat[j] + SORT[i].newtime; } temp = Math.Max(temp, xuat[i]); } } Console.WriteLine(temp); int n = NextInt(); int[] input = new int[100]; input[0] = 1; input[1] = 0; input[2] = 3; input[4] = 11; for (int i = 6; i <= n; i+=2) { input[i] = 4*input[i - 2] - input[i - 4]; } using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Numerics; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { List<BigInteger> test = new List<BigInteger>(); StringBuilder kq = new StringBuilder(); int t = NextInt(); for(int k = 0; k < t; k++) { int n = NextInt(); BigInteger[] ds = new BigInteger[n+1]; if( n <= 3) { kq.Append(n + "\n"); } else { ds[0] = 0; ds[1] = 1; ds[2] = 2; for (int i = 3; i <= n; i++) { ds[i] = ds[i - 1] + ds[i - 2]; } kq.Append(ds[n] + "\n"); } } Console.WriteLine(kq); Console.ReadKey(); } #region Input wrapper static int s_index = 0; static string[] s_tokens; private static string Next() { while (s_tokens == null || s_index == s_tokens.Length) { s_tokens = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); s_index = 0; } return s_tokens[s_index++]; } private static int NextInt() { return Int32.Parse(Next()); } private static long NextLong() { return Int64.Parse(Next()); } private static Double NextDouble() { return Double.Parse(Next()); } #endregion } } using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Numerics; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { List<BigInteger> test = new List<BigInteger>(); StringBuilder kq = new StringBuilder(); int t = NextInt(); for(int k = 0; k < t; k++) { int n = NextInt(); BigInteger[] ds = new BigInteger[n+1]; if( n == 1) { kq.Append(n + "\n"); } else if(n == 2 ) { kq.Append(3 + "\n"); } else { ds[0] = 1; ds[1] = 1; ds[2] = 3; for (int i = 3; i <= n; i++) { ds[i] = ds[i - 1] + 2*ds[i - 2]; } kq.Append(ds[n] + "\n"); } } Console.WriteLine(kq); Console.ReadKey(); } #region Input wrapper static int s_index = 0; static string[] s_tokens; private static string Next() { while (s_tokens == null || s_index == s_tokens.Length) { s_tokens = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); s_index = 0; } return s_tokens[s_index++]; } private static int NextInt() { return Int32.Parse(Next()); } private static long NextLong() { return Int64.Parse(Next()); } private static Double NextDouble() { return Double.Parse(Next()); } #endregion } } using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { List<long> test = new List<long>(); while (true) { string[] dic = null; string N = Console.ReadLine(); if (N != null) { dic = N.Split(' '); long a = tinhtoan(Int64.Parse(dic[0]),test); test.Clear(); Console.WriteLine(a); } else { break; } } } public static long tinhtoan(long n, List<long> test) { if (n < 12) { return n; } else { for (var i = 0; i < test.Count; i+=2) { if (n == test[i]) { return test[i + 1]; } } long tong = Math.Max(n, tinhtoan(n / 2, test) + tinhtoan(n / 3, test) + tinhtoan(n / 4, test)); test.Add(n); test.Add(tong); return tong; } } #region Input wrapper static int s_index = 0; static string[] s_tokens; private static string Next() { while (s_tokens == null || s_index == s_tokens.Length) { s_tokens = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); s_index = 0; } return s_tokens[s_index++]; } private static int NextInt() { return Int32.Parse(Next()); } private static long NextLong() { return Int64.Parse(Next()); } private static Double NextDouble() { return Double.Parse(Next()); } #endregion } } using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { List<long> test = new List<long>(); while (true) { string[] dic = null; string N = Console.ReadLine(); if (N != null) { dic = N.Split(' '); long a = tinhtoan(Int64.Parse(dic[0]),test); test.Clear(); Console.WriteLine(a); } else { break; } } } public static long tinhtoan(long n, List<long> test) { if (n < 12) { return n; } else { for (var i = 0; i < test.Count; i+=2) { if (n == test[i]) { return test[i + 1]; } } long tong = Math.Max(n, tinhtoan(n / 2, test) + tinhtoan(n / 3, test) + tinhtoan(n / 4, test)); test.Add(n); test.Add(tong); return tong; } } #region Input wrapper static int s_index = 0; static string[] s_tokens; private static string Next() { while (s_tokens == null || s_index == s_tokens.Length) { s_tokens = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); s_index = 0; } return s_tokens[s_index++]; } private static int NextInt() { return Int32.Parse(Next()); } private static long NextLong() { return Int64.Parse(Next()); } private static Double NextDouble() { return Double.Parse(Next()); } #endregion } } StringBuilder kq = new StringBuilder(); List<double> test = new List<double>(); var coin = NextDouble(); var time = NextDouble(); var lai = NextDouble(); lai = lai / 100; double coingoc = coin / time; for(int i = 1; i <= time;i++) { var laithang = coin * (lai / 12); test.Add(laithang); coin = coin - coingoc; } Console.WriteLine(test.Sum()); Console.ReadKey(); } #region Input wrapper namespace ConsoleApplication1 { class Program { static void Main(string[] args) { List<long> test = new List<long>(); while (true) { string[] dic = null; string N = Console.ReadLine(); if (N != null) { dic = N.Split(' '); long a = tinhtoan(Int64.Parse(dic[0]),test); test.Clear(); Console.WriteLine(a); } else { break; } } } public static long tinhtoan(long n, List<long> test) { if (n < 12) { return n; } else { for (var i = 0; i < test.Count; i+=2) { if (n == test[i]) { return test[i + 1]; } } long tong = Math.Max(n, tinhtoan(n / 2, test) + tinhtoan(n / 3, test) + tinhtoan(n / 4, test)); test.Add(n); test.Add(tong); return tong; } } using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { List<long> test = new List<long>(); while (true) { string[] dic = null; string N = Console.ReadLine(); if (N != null) { dic = N.Split(' '); long a = tinhtoan(Int64.Parse(dic[0]),test); test.Clear(); Console.WriteLine(a); } else { break; } } } public static long tinhtoan(long n, List<long> test) { if (n < 12) { return n; } else { for (var i = 0; i < test.Count; i+=2) { if (n == test[i]) { return test[i + 1]; } } long tong = Math.Max(n, tinhtoan(n / 2, test) + tinhtoan(n / 3, test) + tinhtoan(n / 4, test)); test.Add(n); test.Add(tong); return tong; } } #region Input wrapper static int s_index = 0; static string[] s_tokens; private static string Next() { while (s_tokens == null || s_index == s_tokens.Length) { s_tokens = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); s_index = 0; } return s_tokens[s_index++]; } private static int NextInt() { return Int32.Parse(Next()); } private static long NextLong() { return Int64.Parse(Next()); } private static Double NextDouble() { return Double.Parse(Next()); } #endregion } } using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ChiPhiSinhHoat { class Program { static void Main(string[] args) { StringBuilder kq = new StringBuilder(); int ce = NextInt(); int n = NextInt(); List<int> test = new List<int>(); for (int i = 0; i < n; i++) { test.Add(NextInt()); } //test.Sort(); int[] c = new int[ce + 1]; int[] s = new int[ce + 1]; for(int i = 0; i <= ce; i++) { c[i] = int.MaxValue - 1; s[i] = -1; } c[0] = 0; for(int i = 0; i < n;i++) { for(int j = 1; j <= ce;j++) { if(j >= test[i]) { if( c[j - test[i]] + 1 < c[j]) { c[j] = c[j - test[i]] + 1; s[j] = i; } } } } if(s[ce] == -1) { kq.Append("No" + "\n"); } else { kq.Append(c[ce] + "\n"); while(ce != 0) { kq.Append(test[s[ce]] + " "); ce = ce - test[s[ce]]; } } //for (int i = 1; i < ce + 1; i++) //{ // c[i] = int.MaxValue - 1; //} //for (int i = 1; i < ce + 1; i++) //{ // for (int j = 0; j < n; j++) // { // if (test[j] <= i) // { // if ((c[i - test[j]] + 1) < c[i]) // { // c[i] = (c[i - test[j]] + 1); // s[i] = test[j]; // } // } // } //} //int count = 0; //while (ce != 0) //{ // ce = ce - s[ce]; // count++; //} //for (int i = 0; i < s.Length; i++) //{ // kq.Append(s[i] + " "); //} //Console.WriteLine(count + "\n" + kq); Console.WriteLine(kq); Console.ReadKey(); } #region Input wrapper //giup viec quan ly khoi static int s_index = 0; static string[] s_tokens; private static string Next() { while (s_tokens == null || s_index == s_tokens.Length) { s_tokens = Console.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); s_index = 0; } return s_tokens[s_index++]; } private static int NextInt() { return Int32.Parse(Next()); } private static long NextLong() { return Int64.Parse(Next()); } #endregion } } } using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ChiPhiSinhHoat { class Program { static void Main(string[] args) { StringBuilder kq = new StringBuilder(); int ce = NextInt(); int n = NextInt(); List<int> test = new List<int>(); for(int i = 0; i < n; i++) { test.Add(NextInt()); } test.Sort(); int[] c = new int[ce + 1]; int[] s = new int[ce + 1]; for(int i = 1; i < ce+1;i++) { c[i] = int.MaxValue; } for(int i = 1; i < ce+1;i++) { for(int j = 0; j < n;j++) { if(test[j] <= i) { if(c[i - test[j]] + 1 < c[i]) { c[i] = (c[i - test[j]] + 1); s[i] = test[j]; } } } } int count = 0; while(ce != 0) { ce = ce - s[ce]; count++; } for (int i = 0; i < s.Length; i++) { kq.Append(s[i] + " "); } Console.WriteLine(count + "\n" + kq); Console.ReadKey(); } #region Input wrapper //giup viec quan ly khoi static int s_index = 0; static string[] s_tokens; private static string Next() { while (s_tokens == null || s_index == s_tokens.Length) { s_tokens = Console.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); s_index = 0; } return s_tokens[s_index++]; } private static int NextInt() { return Int32.Parse(Next()); } private static long NextLong() { return Int64.Parse(Next()); } #endregion } } } using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ChiPhiSinhHoat { class Program { static void Main(string[] args) { StringBuilder kq = new StringBuilder(); int ce = NextInt(); int n = NextInt(); List<int> test = new List<int>(); for(int i = 0; i < n; i++) { test.Add(NextInt()); } test.Sort(); int[] c = new int[ce + 1]; int[] s = new int[ce + 1]; for(int i = 1; i < ce+1;i++) { c[i] = int.MaxValue; } for(int i = 1; i < ce+1;i++) { for(int j = 0; j < n;j++) { if(test[j] <= i) { if(c[i - test[j]] + 1 < c[i]) { c[i] = (c[i - test[j]] + 1); s[i] = test[j]; } } } } int count = 0; while(ce != 0) { ce = ce - s[ce]; count++; } for (int i = 0; i < s.Length; i++) { kq.Append(s[i] + " "); } Console.WriteLine(count + "\n" + kq); Console.ReadKey(); } #region Input wrapper //giup viec quan ly khoi static int s_index = 0; static string[] s_tokens; private static string Next() { while (s_tokens == null || s_index == s_tokens.Length) { s_tokens = Console.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); s_index = 0; } return s_tokens[s_index++]; } private static int NextInt() { return Int32.Parse(Next()); } private static long NextLong() { return Int64.Parse(Next()); } #endregion } } } using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ChiPhiSinhHoat { class Program { static void Main(string[] args) { var x = NextInt(); List<int> test = new List<int>(); for(int i = 0; i < 3; i++) { test.Add(NextInt()); } test.Sort(); int[,] ds = new int[3,x+1]; for(int i = 0; i <= x; i++) { ds[0, i] = 1; } for(int i = 0; i < 3; i++) { ds[i, 0] = 1; } for(int i = 1; i < 3; i++) { for(int j = 0; j <= x;j++) { if(j >= test[i]) { ds[i, j] = ds[i - 1, j] + ds[i, j - test[i]]; } else { ds[i, j] = ds[i - 1, j]; } } } ////int tien = NextInt(); ////long[] vatpham = new long[3]; ////int[] xuat = new int[tien + 1]; ////int[] danhdau = new int[tien + 1]; ////danhdau[0] = 1; ////for (int i = 0; i < 3; i++) ////{ //// int si = NextInt(); //// vatpham[i] = si; ////} ////for (int i = 0; i <= tien; i++) ////{ //// if (danhdau[i] != 1) //// { //// continue; //// } //// for (int j = 0; j < 3; j++) //// { //// if (i + vatpham[j] <= tien) //// { //// xuat[i + vatpham[j]] = Math.Min(xuat[i + vatpham[j]], xuat[i] + 1); //// danhdau[i + vatpham[j]] = 1; //// } //// } ////} Console.WriteLine(ds[2,x]); Console.ReadKey(); } #region Input wrapper //giup viec quan ly khoi static int s_index = 0; static string[] s_tokens; private static string Next() //kieu ky tu { while (s_tokens == null || s_index == s_tokens.Length) { s_tokens = Console.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); s_index = 0; } return s_tokens[s_index++]; } private static int NextInt() //kieu so nguyen { return Int32.Parse(Next()); //bien ky tu vao ra so nguyen } private static long NextLong() //kieu so lon { return Int64.Parse(Next()); //giong tren } #endregion //ket khuc } } using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { long dem = 0; StringBuilder kq = new StringBuilder(); List<long> test = new List<long>(); while (dem <= 10) { dem++; long count = 0; string[] dic = null; string N = Console.ReadLine(); if (N != null) { dic = N.Split(' '); long n = Int64.Parse(dic[0]); tinhtoan(n, test); foreach(var a in test) { count += a; } kq.Append(count + "\n"); } else { break; } } Console.Write(kq); Console.ReadKey(); } public static void tinhtoan(long n, List<long> test) { long tong = n / 2 + n / 3 + n / 4; if(tong > n) { tinhtoan(n / 2, test); tinhtoan(n / 3, test); tinhtoan(n / 4, test); } else { test.Add(n); } } #region Input wrapper static int s_index = 0; static string[] s_tokens; private static string Next() { while (s_tokens == null || s_index == s_tokens.Length) { s_tokens = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); s_index = 0; } return s_tokens[s_index++]; } private static int NextInt() { return Int32.Parse(Next()); } private static long NextLong() { return Int64.Parse(Next()); } private static Double NextDouble() { return Double.Parse(Next()); } #endregion } } var c = Console.Read(); var n = Console.Read(); List<int> test = new List<int>(); for(int j = 1; j <= n.; j++) { test.Add(Console.Read()); } int count = 0; test.Sort(); int i = test.Count - 1; while(c > 0) { while (test[i] <= c) { c = c - test[i]; count++; } if (c == 0) { break; } } Console.WriteLine(count); Console.ReadLine(); Console.ReadKey(); using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { var N = NextInt(); StringBuilder kq = new StringBuilder(); int hang = 0; int dat = 0; int count = 0; int count1 = 0; for ( int i = 0; i < N; i++) { string a = Next(); while (a.Length > 1) { for (int j = 0; j < a.Length; j++) { if (a[j] == 'H') { if ((j + 1) < a.Length) { if (a[j + 1] == 'T') { a = a.Remove(j, 2); dat++; break; } } } } for (int j = 0; j < a.Length; j++) { if (a[j] == 'T') { if ((j + 1) < a.Length) { if (a[j + 1] == 'H') { a = a.Remove(j, 2); hang++; break; } } } } } if( a.Length == 0) { if (hang > dat) { count++; } else if (hang < dat) { count1++; } } else if( a.Length == 1) { if ( a[0] == 'H') { count++; } else if( a[0] == 'T') { count1++; } } else { if (a[0] == 'H') { count++; } else if (a[0] == 'T') { count1++; } } } kq.Append(count + " " + count1); Console.Write(kq); Console.ReadKey(); } #region Input wrapper static int s_index = 0; static string[] s_tokens; private static string Next() { while (s_tokens == null || s_index == s_tokens.Length) { s_tokens = Console.ReadLine().Split(new[] { ' ', '\r', '\n', '\t' }, StringSplitOptions.RemoveEmptyEntries); s_index = 0; } return s_tokens[s_index++]; } private static int NextInt() { return Int32.Parse(Next()); } private static long NextLong() { return Int64.Parse(Next()); } private static Double NextDouble() { return Double.Parse(Next()); } #endregion } } using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { var N = NextInt(); StringBuilder kq = new StringBuilder(); StringBuilder kq1 = new StringBuilder(); int count = 0; int dem = 0; int[] ai = new int[N]; for (int i = 0; i < N; i++) { ai[i] = NextInt(); } int luu; for (int i = 0; i < N; i++) { for (int j = i + 1; j < N; j++) { if (ai[i] < ai[j]) { count++; } else if( ai[i] > ai[j]) { luu = ai[i]; ai[i] = ai[j]; ai[j] = luu; count++; } } } //for( int i=0; i < N; i++) //{ // kq.Append(ai[i] + " "); //} //int m = kq[0]; //for (int i = 0; i < N; i++) //{ // if (m > kq[i]) // { // m = kq[i]; // count++; // } //} kq1.Append(count); Console.Write(kq1); Console.ReadKey(); } #region Input wrapper static int s_index = 0; static string[] s_tokens; private static string Next() { while (s_tokens == null || s_index == s_tokens.Length) { s_tokens = Console.ReadLine().Split(new[] { ' ', '\r', '\n', '\t' }, StringSplitOptions.RemoveEmptyEntries); s_index = 0; } return s_tokens[s_index++]; } private static int NextInt() { return Int32.Parse(Next()); } private static long NextLong() { return Int64.Parse(Next()); } private static Double NextDouble() { return Double.Parse(Next()); } #endregion } }

Các lần nộp bài đã được ghi nhân
(Xem dạng tệp tin văn bản)

Problems

Danh sách các bài đã làm đạt yêu cầu:

LATGACH

Danh sách các bài làm chưa đạt yêu cầu:

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.