- (void)loadZip {
NSString *mainUrl = [self.server stringByAppendingString:@"/files/YOURZIP.zip"];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:mainUrl]];
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *respons,
NSData *dat,
NSError *connectionError) {
if (!connectionError) {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *appFile = [documentsDirectory stringByAppendingPathComponent:@"YOURZIP.zip"];
NSError *error;
BOOL flag = [dat writeToFile:appFile options:NSDataWritingAtomic error:&error];
if (flag) {
NSLog(@"You cool");
} else {
NSLog(@"%@", error.localizedDescription);
[self loadZip];
}
} else {
NSLog(@"%@",[connectionError localizedDescription]);
}
}];
}
#include <iostream>
using namespace std;
struct elem {
float data;
int pos;
};
int main(int argc, const char * argv[]) {
int N;
cin >> N;
if (N<7) {
cout<<"Corrupted data";
}
elem minVal[13];
for (int i=0; i<13; i++) {
minVal[i] = {10001.0f+i,0};
}
float in;
bool flag = true;
for (int i=0; i<N; i++) {
cin>>in;
flag = true;
for (int j=0; j<13 && flag; j++) {
if (minVal[j].data>in) {
flag = false;
for (int i2=12; i2>j; i2--) {
minVal[i2] = minVal[i2-1];
}
minVal[j] = {in, i};
}
}
}
float result = INT_MAX;
float mult = .0f;
int delta = 0;
for (int i=0; i<12; i++) {
for (int j=i+1; j<13; j++) {
mult = minVal[i].data*minVal[j].data;
delta = abs(minVal[i].pos-minVal[j].pos);
if (delta>=6 && result>mult) {
result = minVal[i].data*minVal[j].data;
}
}
}
cout<<result<<endl;
return 0;
}
@interface MyViewController () {
NSTimer *timer;
int seconds;
...
}
@property (weak, nonatomic) IBOutlet UILabel *timerLabel;
@end
...
- (void)viewDidLoad
{
[super viewDidLoad];
timer = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(updateTimer:) userInfo:nil repeats:YES];
[self.timerLabel setText:@"1:00"]
seconds = 60;
}
- (void)updateTimer:(NSTimer *)theTimer {
if (seconds>0) {
seconds--;
int min = seconds/60;
int sec = seconds%60;
[timerLabel setText:[NSString stringWithFormat:@"%01d:%02d",min,sec]];
} else {
[timer invalidate];
NSLog(@"Timer end");
}
}