Norek Posted October 21, 2008 Report Share Posted October 21, 2008 nu jā. tur jau tā visa sāls, atrast paternu, pēc kāda tiek iegūti nākošie skaitļi skaitļu virknē. Link to comment Share on other sites More sharing options...
vincister Posted October 21, 2008 Report Share Posted October 21, 2008 1) A high school has a strange principal. On the first day, he has his students perform an odd opening day ceremony: There are one thousand lockers and one thousand students in the school. The principal asks the first student to go to every locker and open it. Then he has the second student go to every second locker and close it. The third goes to every third locker and, if it is closed, he opens it, and if it is open, he closes it. The fourth student does this to every fourth locker, and so on. After the process is completed with the thousandth student, how many lockers are open? Es esmu slinks... #include <iostream> using namespace std; int main(){ int locker[1001]; int counter=0; for(int i=1; i<1002; i++){ locker[i]=0; } for(int i=1; i<1002;i++){ for(int j=i;j<1002;j=j+i){ if(locker[j]==0) locker[j]=1; else locker[j]=0; } } for(int i=1; i<1002; i++){ if(locker[i]==1) counter++; cout<<locker[i]<<" "; } cout<<'\n'<<counter<<'\n'; return 0; } Link to comment Share on other sites More sharing options...
Dr. Pain Posted October 21, 2008 Report Share Posted October 21, 2008 Nerakstīšu pilnus atrisinājumus, lai pārējiem interesantāk risināt Atrisinājums durvīm - jāskatās dalāmo skaits Atrisinājums maisiem - jāliek uz svariem monētas no katra maisa (te gan būs atrisinājums) 77, 143, 221, 323, 437 - 667 Link to comment Share on other sites More sharing options...
Dr. Pain Posted October 22, 2008 Report Share Posted October 22, 2008 1, 5, 32, 288, 3413, 50069 Man pēdējam uzdevumam vajag kādu ierobežojošu faktoru (piemēram, katru nākamo virknes locekli vai iegūt no iepriekšējā vai ko tādu). Citādi es pieņemu, ka atrisinājums ir šāds: pirmie trīs virknes locekļi ir definēti (100, 121, 144) un katru nākamo var aprēķināt pēc formulas a(n) = a(n-3)*2+2 Link to comment Share on other sites More sharing options...
Norek Posted October 22, 2008 Report Share Posted October 22, 2008 Tur nekas nav tā pat vien definēts. Nākošo var atrast, atrodot sakarību starp iepriekšējiem. Atbilde ir pareiza, risinājums gan uzrādīts savādāks. Solution: 1 = 1^1 5 = 1^1 + 2^2 32 = 1^1 + 2^2 + 3^3 288 = 1^1 + 2^2 + 3^3 + 4^4 3413 = 1^1 + 2^2 + 3^3 + 4^4 + 5^5 50069 = 1^1 + 2^2 + 3^3 + 4^4 + 5^5 + 6^6 Link to comment Share on other sites More sharing options...
Norek Posted October 22, 2008 Report Share Posted October 22, 2008 Pats arī vienu izdomāju : Atrodot sakarību skaitļu virknē, uzrakstīt nākošo virknes loceki. Kaut gan atbilde mani neinteresē, mani interesē risinājums 1, 6, 120, 5040, 362880 Link to comment Share on other sites More sharing options...
Dr. Pain Posted October 22, 2008 Report Share Posted October 22, 2008 Šitais bija pārāk viegls - a(n) = (2*n-1)! Link to comment Share on other sites More sharing options...
Norek Posted October 22, 2008 Report Share Posted October 22, 2008 Es visu laiku domāju, what the ..., līdz ieraudzīju izsaukuma zīmi Link to comment Share on other sites More sharing options...
Dr. Pain Posted October 22, 2008 Report Share Posted October 22, 2008 Varat pamēģināt šo 6, 6, 7, 9, 10, 10, 14, 14, 15, 16 Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now